From 5cb741c81004fda26188f942890682a9747d9bec Mon Sep 17 00:00:00 2001 From: ABE-Mark45 Date: Tue, 12 Dec 2023 11:00:29 +0200 Subject: [PATCH] [FIX] mrp_subcontracting: fix BOM calculation to include warehouse stock In BoM overview report, the free quantity and the on hand quantity only reflected the available stock in subcontracting location. After this commit, selected warehouse stock is also included in the calculation. task-3632211 Part-of: odoo/odoo#145889 --- .../report/mrp_report_bom_structure.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/addons/mrp_subcontracting/report/mrp_report_bom_structure.py b/addons/mrp_subcontracting/report/mrp_report_bom_structure.py index e048d2c562e..6072998f322 100644 --- a/addons/mrp_subcontracting/report/mrp_report_bom_structure.py +++ b/addons/mrp_subcontracting/report/mrp_report_bom_structure.py @@ -88,6 +88,7 @@ class ReportBomStructure(models.AbstractModel): @api.model def _get_quantities_info(self, product, bom_uom, product_info, parent_bom=False, parent_product=False): + quantities_info = super()._get_quantities_info(product, bom_uom, product_info, parent_product) if parent_product and parent_bom and parent_bom.type == 'subcontract' and product.type == 'product': route_info = product_info.get(parent_product.id, {}).get(parent_bom.id, {}) if route_info and route_info['route_type'] == 'subcontract': @@ -97,13 +98,11 @@ class ReportBomStructure(models.AbstractModel): stock_loc = f"subcontract_{subcontracting_loc.id}" if not product_info[product.id]['consumptions'].get(stock_loc, False): product_info[product.id]['consumptions'][stock_loc] = 0 - return { - 'free_qty': product.uom_id._compute_quantity(subloc_product.free_qty, bom_uom), - 'on_hand_qty': product.uom_id._compute_quantity(subloc_product.qty_available, bom_uom), - 'stock_loc': stock_loc, - } + quantities_info['free_qty'] += product.uom_id._compute_quantity(subloc_product.free_qty, bom_uom) + quantities_info['on_hand_qty'] += product.uom_id._compute_quantity(subloc_product.qty_available, bom_uom) + quantities_info['stock_loc'] = stock_loc - return super()._get_quantities_info(product, bom_uom, product_info, parent_product) + return quantities_info @api.model def _get_resupply_availability(self, route_info, components):