0
votes

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? ...

1
If possible can you please share your sample code here.Mital Vaghani
I used odoo developer mode on Saas. Here is XML view in sale.order.line <field name="x_product_customer_reference" string="Product Customer Reference" context="{'default_x_customer_id': order_partner_id, 'default_x_product_id': product_id}"/> My custom model x_customer_product_reference has two many2one fields, x_customer_id and x_product_id.Koul
also domains are working well, but will not work to set a default valueKoul

1 Answers

1
votes

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}"/>