[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.
This commit is contained in:
Josse Colpaert
2017-09-27 18:10:20 +02:00
committed by amoyaux
parent a11d4174a2
commit fc680f5a6b
2 changed files with 4 additions and 3 deletions
+3 -2
View File
@@ -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({
+1 -1
View File
@@ -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: