api.depends问题
未解决
Odoo 新手求助
-
class MrpLine(models.Model): _name = 'mrp.line' plant_queue = fields.One2many(comodel_name='mrp.plant', inverse_name='assembly_line_id', domain=([('state', '=', 'start')]) ) on_going_plant_id = fields.Many2one('mrp.plant', readonly=True, store=True, compute="_compute_on_going_plant") on_going_order_id = fields.Many2one(related='on_going_plant_id.k3_order_id', store=True, readonly=True) @api.depends('plant_queue') def _compute_on_going_plant(self): # 用于修改on_going_plant_id ... class MrpPlant(models.Model): _name = 'mrp.plant' k3_order_id = fields.Many2one('k3.order', required=True) assembly_line_id = fields.Many2one('mrp.line', related='k3_order_id.exec_mrp_line_id', readonly=True) state = fields.Selection(selection=[('start', '开始'), ('stop', '停止')], default='start') def change(self): # 修改状态 ...
在MrpLine的菜单中修改时,或者在mrp.plant创建时会触发MrpLine的_compute_on_going_plant
但是在MrpPlant里的方法修改当前数据时,并不会触发MrpLine的_compute_on_going_plant。
请问要怎么处理,谢谢各位! -
你可以试试把
mrp.plant
中的触发字段加到depends里,比如:@api.depends('plant_queue', 'plant_queue.state') def _compute_on_going_plant(self):