[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 <tic@odoo.com>
This commit is contained in:
Khoa-Jocelyn
2023-02-27 17:07:54 +01:00
committed by Tiffany Chang (tic)
parent 6d5586801a
commit d67c0debaa
+1 -1
View File
@@ -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: