Make stock_available_mrp compatible with other modules like stock_available_immediately

This commit is contained in:
Florian da Costa
2019-07-06 17:31:36 +02:00
committed by ps-tubtim
parent a0f835afe0
commit 29dfe25d3f

View File

@@ -27,13 +27,15 @@ class ProductTemplate(models.Model):
res = {}
for template in self:
immediately_usable_qty = sum(
[variants_dict[p.id]["immediately_usable_qty"] for p in
[variants_dict[p.id]["immediately_usable_qty"] -
variants_dict[p.id]["potential_qty"] for p in
template.product_variant_ids])
potential_qty = max(
[variants_dict[p.id]["potential_qty"] for p in
template.product_variant_ids] or [0.0])
res[template.id] = {
"immediately_usable_qty": immediately_usable_qty,
"immediately_usable_qty": immediately_usable_qty +
potential_qty,
"potential_qty": potential_qty,
}
return res