From 1b68187840f357654d3709c1918e5903592ee8e2 Mon Sep 17 00:00:00 2001 From: Alejandro Ji Cheung Date: Fri, 7 Mar 2025 11:20:13 +0100 Subject: [PATCH] [FIX] stock_available_mrp: don't add potential_qty to immediately_usable_qty if bom_id.type == "phantom" {odoo-16/fl-v16#5582} --- stock_available_mrp/models/product_product.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/stock_available_mrp/models/product_product.py b/stock_available_mrp/models/product_product.py index 6bf3c518..b1876b34 100644 --- a/stock_available_mrp/models/product_product.py +++ b/stock_available_mrp/models/product_product.py @@ -77,7 +77,13 @@ def _compute_available_quantities_dict(self): ) res[product.id]["potential_qty"] = potential_qty - res[product.id]["immediately_usable_qty"] += potential_qty + # if product has kit, immediately_usable_qty = potential_qty + # else immediately_usable_qty += potential_qty, because we don't + # want to duplicate the qty in immediate_usable_qty if it's a kit + if bom_id.type == "phantom": + res[product.id]["immediately_usable_qty"] = potential_qty + else: + res[product.id]["immediately_usable_qty"] += potential_qty return res, stock_dict @@ -124,9 +130,11 @@ def explode_bom_quantities(self): for product in self: lines_done = [] + bom_id = first( + product.bom_ids.filtered(lambda bom, p=product: bom.product_id == p) + ) or first(product.bom_ids) bom_lines = [ - (first(product.bom_ids), bom_line, product, 1.0) - for bom_line in first(product.bom_ids).bom_line_ids + (bom_id, bom_line, product, 1.0) for bom_line in bom_id.bom_line_ids ] while bom_lines: