From cd958ff641f40ff8371abc3b219dc49c2fc1aa19 Mon Sep 17 00:00:00 2001 From: david Date: Tue, 23 Nov 2021 13:36:15 +0100 Subject: [PATCH] [FIX] stock_picking_report_valued_sale_mrp: multipicking When the recordset comes from multiple picking we could get a wrong calculation of the mrp lines in the report when the conditions of same component for the same order line would apply. So for every picking we have to compute the kits valuations independently. TT33076 --- .../models/stock_move_line.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/stock_picking_report_valued_sale_mrp/models/stock_move_line.py b/stock_picking_report_valued_sale_mrp/models/stock_move_line.py index 3cf1699..6c8db23 100644 --- a/stock_picking_report_valued_sale_mrp/models/stock_move_line.py +++ b/stock_picking_report_valued_sale_mrp/models/stock_move_line.py @@ -35,6 +35,14 @@ class StockMoveLine(models.Model): avoid duplicate the amounts. We also need to recompute the total amounts according to the corresponding delivered kits""" super()._compute_sale_order_line_fields() + for picking in self.mapped("picking_id"): + self.filtered( + lambda x: x.picking_id == picking + )._compute_sale_order_line_fields_by_picking() + + def _compute_sale_order_line_fields_by_picking(self): + """We want to compute the lines value by picking to avoid mixing lines + if they wen't altogether""" kit_lines = self.filtered("phantom_product_id") for sale_line in kit_lines.mapped("sale_line"): move_lines = kit_lines.filtered(