Aide

0

how to pass the data to controller from custom webform

Avatar
prabath

I have create a custom webform to change product quantity in picking . and  form view is working with data correctly . it's a table view.

I want to know after change the field quantity, how to pass the value to controller . all rows are together.


this is a part of my form template.  i have used input name with brackets but only pass first row values only. please help me how to transfer the dynamic field data from webform to the controller

odoo version-12.0


<t t-foreach="orders_ids" t-as="o">
    <tr style="border-bottom:1px solid black;" >
        <td style="width:10%;">   
            <input type="text" name="pick_id[]" t-att-value="o.name"  />                          
        </td>
                                            
        <td class="text-right"  style="width:20%">
            <input type="number" name="quantity[]" min="0" style="width:100%" t-att-value="o.product_uom_qty" />   
                                    
        </td>
        <td  class="text-right" style="width:20%">   
            <input type="number" name="quantity_done[]" min="0" style="width:100%" t-att-value="o.quantity_done" />                         
        </td>
    </tr>
</t>   


                                    


Avatar
Annuler
1Réponse
0
Meilleure réponse

Hi,

We can pass the data to a custom controller using ajax.rpc method.

var a = "Hello"
ajax.rpc('/webform',{a})

here {a} contain data that accessible from controller in dictionary form

@http.route(['/webform'], type='json', auth="public")
def function_name(self,**kwargs ):
print(kwargs)

While printing the kwargs in the function of our controller we will get Hello as the result.

Regards

Avatar
Annuler