Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions stock_available_mrp/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down
Loading