Help

欢迎!

该社区面向专业人士和我们产品和服务的爱好者。
分享和讨论最好的内容和新的营销理念,建立您的专业形象,一起成为更好的营销人员。


0

pass value from sale.order.line to stock.move in odoo 16

Avatar
odoo
Avatar
Discard
1 Answer
0
Avatar
odoo
Best Answer

If you just want to have the same value from Sale Order Line in Stock Move, you should slightly modify you field definition in your stock.move inherit.

The module sale_stock introduces a new field, sale_line_id.

So, given dependencies add up, you can simply go for

class StockMove(models.Model):
    _inherit = 'stock.move'

    x_studio_roles = fields.Float(related='sale_line_id.x_studio_roles', readonly=False)


This defines a direct relationship between those two fields, see also https://www.odoo.com/documentation/16.0/developer/reference/backend/orm.html#reference-fields-related

Note that editing x_studio_roles on Stock Move now also changes the value in Sale Order Line.

If you don't want that you can go for a "computed field" - which would allow you to set it only initially when the Stock Move is created and you then could check whether this field is set already and prevent further updates to it. What and how to apply this highly depends on what you would like to achieve at the end. For details about computed fields see https://www.odoo.com/documentation/16.0/developer/reference/backend/orm.html#computed-fields

Avatar
Discard