Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] stock_product_pack: discriminate outgoing qty in available qty for packs #176

Draft
wants to merge 2 commits into
base: 16.0
Choose a base branch
from
Draft
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
27 changes: 24 additions & 3 deletions stock_product_pack/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,37 @@ def _compute_quantities_dict(
)
for subproduct in subproducts:
subproduct_stock = subproduct.product_id
subproduct_stock_qties = subproduct_stock._compute_quantities_dict(
lot_id, owner_id, package_id, from_date=from_date, to_date=to_date
)
sub_qty = subproduct.quantity
if sub_qty:
pack_qty_available.append(
math.floor(subproduct_stock.qty_available / sub_qty)
math.floor(
(
subproduct_stock_qties[subproduct_stock.id].get(
"qty_available"
)
- subproduct_stock_qties[subproduct_stock.id].get(
"outgoing_qty"
)
)
/ sub_qty
)
)
pack_virtual_available.append(
math.floor(subproduct_stock.virtual_available / sub_qty)
math.floor(
subproduct_stock_qties[subproduct_stock.id].get(
"virtual_available"
)
/ sub_qty
)
)
pack_free_qty.append(
math.floor(subproduct_stock.free_qty / sub_qty)
math.floor(
subproduct_stock_qties[subproduct_stock.id].get("free_qty")
/ sub_qty
)
)
res[product.id] = {
"qty_available": (pack_qty_available and min(pack_qty_available) or 0),
Expand Down
Loading