I have 2 one2many field named "measure" in res.partner and sale.order.line .I want that when I select customer in sale order form , it record the contents of the res.partner field (measure) in the field "measure" of order line.
I can do this via the onchange method but when I save the sale order , the value of "measure" field on sale order line becomes empty. Can someone help me to solve the problem?
Here is my code
class res_partner(models.Model):
_name = 'res.partner'
_inherit = 'res.partner'
measure= fields.One2many('order.mesure', 'partner', string='Measures')
class Sale_order_line(models.Model):
_name = 'sale.order.line'
_inherit = 'sale.order.line'
measure= fields.One2many('order.mesure', 'sale_line', string=" Measures", store=True)
@api.onchange('mesures')
def onchange_measure(self):
if self.order_id.partner_id:
self.measure = self.order_id.partner_id.measure
Thank you