summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Henrotin <whe@odoo.com>2018-10-15 13:20:52 +0000
committerWilliam Henrotin <whe@odoo.com>2018-10-15 13:20:52 +0000
commitf652c8d1dafd5000fa666eb8ec6a41735b74a61a (patch)
tree61efcbc5ff6ee9ccebc276e4fdbc7b8938ac1bbd
parent6c42ca8a7be54a7a6a68461584017fbe4f66cf58 (diff)
[FIX] mrp: done workorder on multiple reserved move lines
Producing a manufacturing order on components with more than one unit could leads to multiple move line reserved on this component. Marking the workorder as done, in that case, will trigger an error saying "Cannot set the done quantity from this stock move, work directly with the move lines". Instead of setting the quantity done directly, this commit uses the magical function _set_quantity_done() that manage the case of more than one move lines. OPW-1888780 closes odoo/odoo#27773
-rw-r--r--addons/mrp/models/mrp_workorder.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/addons/mrp/models/mrp_workorder.py b/addons/mrp/models/mrp_workorder.py
index 8bbe08d4570..723b0d596bf 100644
--- a/addons/mrp/models/mrp_workorder.py
+++ b/addons/mrp/models/mrp_workorder.py
@@ -317,8 +317,10 @@ class MrpWorkorder(models.Model):
if self.product_id.tracking != 'none':
qty_to_add = float_round(self.qty_producing * move.unit_factor, precision_rounding=rounding)
move._generate_consumed_move_line(qty_to_add, self.final_lot_id)
- else:
+ elif len(move._get_move_lines()) < 2:
move.quantity_done += float_round(self.qty_producing * move.unit_factor, precision_rounding=rounding)
+ else:
+ move._set_quantity_done(move.quantity_done + float_round(self.qty_producing * move.unit_factor, precision_rounding=rounding))
# Transfer quantities from temporary to final move lots or make them final
for move_line in self.active_move_line_ids: