diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py index 0d9e9a1ee7f5c..062bebd4fcb29 100644 --- a/addons/mrp/models/mrp_production.py +++ b/addons/mrp/models/mrp_production.py @@ -727,6 +727,9 @@ def _check_production_lines(self): raise ValidationError(_("The component %s should not be the same as the product to produce.") % production.product_id.display_name) def write(self, vals): + if 'move_byproduct_ids' in vals and 'move_finished_ids' not in vals: + vals['move_finished_ids'] = vals['move_byproduct_ids'] + del vals['move_byproduct_ids'] if 'workorder_ids' in self: production_to_replan = self.filtered(lambda p: p.is_planned) res = super(MrpProduction, self).write(vals) diff --git a/addons/mrp/tests/test_byproduct.py b/addons/mrp/tests/test_byproduct.py index 0249e2cc489ed..269cafae2e959 100644 --- a/addons/mrp/tests/test_byproduct.py +++ b/addons/mrp/tests/test_byproduct.py @@ -69,6 +69,7 @@ def test_00_mrp_byproduct(self): # I consume and produce the production of products. # I create record for selecting mode and quantity of products to produce. mo_form = Form(mnf_product_a) + mnf_product_a.move_byproduct_ids.quantity_done = 2 mo_form.qty_producing = 2.00 mnf_product_a = mo_form.save() # I finish the production order.