From 491d22e1df3f6324b81636a89bc8cd9cfd43b9fc Mon Sep 17 00:00:00 2001 From: Om Rabara Date: Thu, 1 Jun 2023 10:29:36 +0000 Subject: [PATCH] [FIX] mrp: fix singleton error while multiple moves in 'move_finished_ids' ValueError: Expected singleton: stock.move(32, 33) This error occurs when we get the multiple lines of the same products in 'finish_moves' and after that when we try to mark as done at that time this error occurs. applying these changes will resolve this issue. sentry-4217897073 closes odoo/odoo#124251 X-original-commit: 4933609bd6a8473272f6bb94a1de8aea5cdf6687 Signed-off-by: Tiffany Chang --- addons/mrp/models/mrp_production.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py index b87445f646b..404eae2533a 100644 --- a/addons/mrp/models/mrp_production.py +++ b/addons/mrp/models/mrp_production.py @@ -1508,10 +1508,12 @@ class MrpProduction(models.Model): for order in self: finish_moves = order.move_finished_ids.filtered(lambda m: m.product_id == order.product_id and m.state not in ('done', 'cancel')) # the finish move can already be completed by the workorder. - if finish_moves and not finish_moves.quantity_done: - finish_moves._set_quantity_done(float_round(order.qty_producing - order.qty_produced, precision_rounding=order.product_uom_id.rounding, rounding_method='HALF-UP')) - if finish_moves.has_tracking != 'none' and order.lot_producing_id: - finish_moves.move_line_ids.lot_id = order.lot_producing_id + for move in finish_moves: + if move.quantity_done: + continue + move._set_quantity_done(float_round(order.qty_producing - order.qty_produced, precision_rounding=order.product_uom_id.rounding, rounding_method='HALF-UP')) + if move.has_tracking != 'none' and order.lot_producing_id: + move.move_line_ids.lot_id = order.lot_producing_id # workorder duration need to be set to calculate the price of the product for workorder in order.workorder_ids: if workorder.state not in ('done', 'cancel'):