Hello,
I have a Many2many fields in sale order form, and I want that only that order line will show in many2many fields related to that sale order. So what domain I will use.
I have also made a field in order line name 'number' of char type in which when we create order line then the same sale order name is copied in 'number ' field. This field I have created to make relationship between sale order and sale order line.
Code:
sale.py.
class SaleOrder(models.Model):
item_delivered_ids = fields.Many2many('sale.order.line',
'sale_order_sale_order_line_rel',
'sale_order_id',
'order_line_id',
string='Item Delivered')
class SaleOrderLine(models.Model):
number = fields.Char(string='Order Number')
sale_view.xml:
<record id="view_sale_order_form_inherit" model="ir.ui.view">
<field name="name">sale.order.form.inherited</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='partner_id']" position="after>
<field name="item_delivered_ids" widget="many2many_tags" />
</xpath>
</field>
</record>
Thanks,
Populate related values in a field on the change of many2one filed.
http://learnopenerp.blogspot.com/2016/10/onchange-many2one-filed-in-odoo.html