From aa61d9fa87359e29f230ce4dfe10e18b4e39d9e0 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 --- .../__manifest__.py | 2 +- .../models/stock_move_line.py | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/stock_picking_report_valued_sale_mrp/__manifest__.py b/stock_picking_report_valued_sale_mrp/__manifest__.py index ce515eb..c1a34d5 100644 --- a/stock_picking_report_valued_sale_mrp/__manifest__.py +++ b/stock_picking_report_valued_sale_mrp/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Valued picking linked with MRP Kits", "summary": "Allow to summarize the picking related with the selled kits", - "version": "13.0.1.0.2", + "version": "13.0.1.0.3", "development_status": "Beta", "category": "Warehouse Management", "website": "https://github.com/OCA/stock-logistics-reporting", 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 718d3c1..f8a8d3a 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 @@ -37,13 +37,22 @@ class StockMoveLine(models.Model): amounts according to the corresponding delivered kits""" super()._compute_sale_order_line_fields() pickings = self.mapped("picking_id") - kit_lines = pickings.move_line_ids.filtered("phantom_product_id") pickings.move_line_ids.update( {"phantom_line": False, "phantom_delivered_qty": 0.0} ) + for picking in pickings: + 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 weren't shipped altogether. + """ + kit_lines = self.filtered("phantom_product_id") for sale_line in kit_lines.mapped("sale_line"): move_lines = kit_lines.filtered(lambda x: x.sale_line == sale_line) - # Deduct the kit quantity from the first component in the picking. + # Deduce the kit quantity from the first component in the picking. # If the the kit is partially delivered, this could lead to an # unacurate value. phantom_line = move_lines[:1]