From fc680f5a6b1dd265af81bd239e3ca4c22d52132b Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Mon, 25 Sep 2017 12:12:43 +0200 Subject: [PATCH] [FIX] mrp: always add theoretical qty on produce Before, in case of non-tracked components, when everything foreseen had already been consumed, it would not add the theoretical quantity on producing through the produce wizard. This makes little sense as the behaviour of the wizard is not the same anymore for all cases and this can only confuse the user. --- addons/mrp/tests/test_unbuild.py | 5 +++-- addons/mrp/wizard/mrp_product_produce.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/mrp/tests/test_unbuild.py b/addons/mrp/tests/test_unbuild.py index f035f2e31b9..e862c37512d 100644 --- a/addons/mrp/tests/test_unbuild.py +++ b/addons/mrp/tests/test_unbuild.py @@ -216,7 +216,8 @@ class TestUnbuild(TestMrpCommon): self.env['stock.quant']._update_available_quantity(p2, self.stock_location, 5) mo.action_assign() for ml in mo.move_raw_ids.mapped('move_line_ids'): - ml.qty_done = ml.product_qty + if ml.product_id.tracking != 'none': + ml.qty_done = ml.product_qty if ml.product_id.tracking != 'none': self.assertEqual(ml.lot_id, lot, 'Wrong reserved lot.') @@ -406,7 +407,7 @@ class TestUnbuild(TestMrpCommon): self.env['stock.quant']._update_available_quantity(p2, self.stock_location, 3, lot_id=lot_2) self.env['stock.quant']._update_available_quantity(p2, self.stock_location, 2, lot_id=lot_3) mo.action_assign() - for ml in mo.move_raw_ids.mapped('move_line_ids'): + for ml in mo.move_raw_ids.mapped('move_line_ids').filtered(lambda m: m.product_id.tracking != 'none'): ml.qty_done = ml.product_qty produce_wizard = self.env['mrp.product.produce'].with_context({ diff --git a/addons/mrp/wizard/mrp_product_produce.py b/addons/mrp/wizard/mrp_product_produce.py index 5462c83bb37..23ed113e49d 100644 --- a/addons/mrp/wizard/mrp_product_produce.py +++ b/addons/mrp/wizard/mrp_product_produce.py @@ -93,7 +93,7 @@ class MrpProductProduce(models.TransientModel): raise UserError(_('You should at least produce some quantity')) for move in self.production_id.move_raw_ids: # TODO currently not possible to guess if the user updated quantity by hand or automatically by the produce wizard. - if move.product_id.tracking == 'none' and move.quantity_done < move.product_uom_qty and move.state not in ('done', 'cancel') and move.unit_factor: + if move.product_id.tracking == 'none' and move.state not in ('done', 'cancel') and move.unit_factor: rounding = move.product_uom.rounding move.quantity_done += float_round(quantity * move.unit_factor, precision_rounding=rounding) for move in self.production_id.move_finished_ids: