Reputation: 87
I have a many2one field in sale.order.line. It is pointing to a custom model with relations to product.product and res.partner.
I want this new field to return the name of a record in the custom model based on the product and the customer (in sale.order.line).
I added <field name="x_product_customer_reference" string="Product Customer Reference" context="{'default_x_customer_id': order_partner_id, 'default_x_product_id': product_id}"/>
in the sale.order.line.form.readonly XML view.
But the new field stays empty. Why is it not working? ...
Upvotes: 0
Views: 1148
Reputation: 372
Please write the below code
<field name="x_product_customer_reference" string="Product Customer Reference" context="{'default_x_customer_id': partner_id, 'default_x_product_id':product_id}"/>
Please note that partner_id field should be there in sale order line, so please create an invisible partner_id field in sale order line otherwise please follow the below code
<field name="x_product_customer_reference" string="Product Customer Reference" context="{'default_x_customer_id': parent.partner_id, 'default_x_product_id':product_id}"/>
Upvotes: 1