diff --git a/mrp_operations_extension/models/mrp_production.py b/mrp_operations_extension/models/mrp_production.py index b2ba9c139..58958f045 100644 --- a/mrp_operations_extension/models/mrp_production.py +++ b/mrp_operations_extension/models/mrp_production.py @@ -56,15 +56,14 @@ class MrpProductionProductLine(models.Model): class MrpProductionWorkcenterLine(models.Model): _inherit = 'mrp.production.workcenter.line' - @api.one + @api.multi + @api.depends('move_lines', 'move_lines.state') def _compute_is_material_ready(self): - self.is_material_ready = True - if self.product_line: - moves = self.env['stock.move'].search( - [('work_order', '=', self.id)]) - self.is_material_ready = not any( + for line in self: + line.is_material_ready = (not any( x not in ('assigned', 'cancel', 'done') for x in - moves.mapped('state')) + line.mapped('move_lines.state')) + if line.product_line else True) @api.multi @api.depends('routing_wc_line') diff --git a/mrp_operations_extension/tests/test_mrp_operations_extension.py b/mrp_operations_extension/tests/test_mrp_operations_extension.py index f18e4f472..f5388fbcc 100644 --- a/mrp_operations_extension/tests/test_mrp_operations_extension.py +++ b/mrp_operations_extension/tests/test_mrp_operations_extension.py @@ -156,6 +156,7 @@ class TestMrpOperationsExtension(common.TransactionCase): self.production.action_confirm() def test_confirm_production_operation_extension_case1(self): + self.assertEqual(self.production.state, 'draft') self.production.signal_workflow('button_confirm') self.assertFalse(self.production.workcenter_lines[0].is_material_ready) self.production.force_production()