diff options
| author | William Henrotin <whe@odoo.com> | 2020-09-08 10:11:36 +0000 |
|---|---|---|
| committer | William Henrotin <whe@odoo.com> | 2020-10-07 13:58:30 +0000 |
| commit | 5d5220ec3187a0813b8b06e6138200e3f7c3d808 (patch) | |
| tree | 694a6917085ddb158a88c1f2ad64486f1799d731 | |
| parent | 9c2d02f6e78a01eca02de90dd9406effa0308d27 (diff) | |
[FIX] mrp: no finished move management
This commit makes sure we do not try to update the quantity on a
finished stock move (during record production or confirming the produce
wizard) if there is no finished move available.
Closes #57227
closes odoo/odoo#59423
X-original-commit: 141df3b398aee2bac10e3ce94e15bb4bd14d17af
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
| -rw-r--r-- | addons/mrp/models/mrp_workorder.py | 4 | ||||
| -rw-r--r-- | addons/mrp/tests/test_order.py | 14 |
2 files changed, 17 insertions, 1 deletions
diff --git a/addons/mrp/models/mrp_workorder.py b/addons/mrp/models/mrp_workorder.py index dcebc190f63..bfa1bac55ab 100644 --- a/addons/mrp/models/mrp_workorder.py +++ b/addons/mrp/models/mrp_workorder.py @@ -762,7 +762,9 @@ class MrpWorkorder(models.Model): lambda move: move.product_id == self.product_id and move.state not in ('done', 'cancel') ) - if production_move and production_move.product_id.tracking != 'none': + if not production_move: + return + if production_move.product_id.tracking != 'none': if not self.finished_lot_id: raise UserError(_('You need to provide a lot for the finished product.')) move_line = production_move.move_line_ids.filtered( diff --git a/addons/mrp/tests/test_order.py b/addons/mrp/tests/test_order.py index a7e024f146e..90f2945d6e6 100644 --- a/addons/mrp/tests/test_order.py +++ b/addons/mrp/tests/test_order.py @@ -1118,6 +1118,20 @@ class TestMrpOrder(TestMrpCommon): details_operation_form.save() mo2.button_mark_done() + def test_product_produce_12(self): + """ Checks that, the production is robust against deletion of finished move.""" + + self.stock_location = self.env.ref('stock.stock_location_stock') + mo, bom, p_final, p1, p2 = self.generate_mo(qty_final=1) + self.assertEqual(len(mo), 1, 'MO should have been created') + + mo_form = Form(mo) + mo_form.qty_producing = 1 + mo = mo_form.save() + # remove the finished move from the available to be updated + mo.move_finished_ids._action_done() + mo.button_mark_done() + def test_product_produce_uom(self): """ Produce a finished product tracked by serial number. Set another UoM on the bom. The produce wizard should keep the UoM of the product (unit) |
