From d67c0debaa6a13940c28bda2a3f4b63440e33e52 Mon Sep 17 00:00:00 2001 From: Khoa-Jocelyn Date: Wed, 15 Feb 2023 04:07:34 +0000 Subject: [PATCH] [FIX] mrp_account: fix error expected singleton If the stock move (consumed_moves) has more than 1 stock valuation layers (stock_valuation_layer_ids), it will cause an expected singleton error. closes odoo/odoo#113764 X-original-commit: 2efe6bea6887ebd6528eba084eb3eaee8af7ab9e Signed-off-by: Tiffany Chang --- addons/mrp_account/models/mrp_production.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mrp_account/models/mrp_production.py b/addons/mrp_account/models/mrp_production.py index adec951ad40..d66045ab23a 100644 --- a/addons/mrp_account/models/mrp_production.py +++ b/addons/mrp_account/models/mrp_production.py @@ -82,7 +82,7 @@ class MrpProduction(models.Model): qty_done = finished_move.product_uom._compute_quantity( finished_move.quantity_done, finished_move.product_id.uom_id) extra_cost = self.extra_cost * qty_done - total_cost = (sum(-m.stock_valuation_layer_ids.value for m in consumed_moves.sudo()) + work_center_cost + extra_cost) + total_cost = - sum(consumed_moves.sudo().stock_valuation_layer_ids.mapped('value')) + work_center_cost + extra_cost byproduct_moves = self.move_byproduct_ids.filtered(lambda m: m.state not in ('done', 'cancel') and m.quantity_done > 0) byproduct_cost_share = 0 for byproduct in byproduct_moves: