[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
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user