Skip to content

Commit aa82f7b

Browse files
Cédric PigeonTimon Tschanz
Cédric Pigeon
authored and
Timon Tschanz
committed
[10.0][CHG]stock_available...: improve stock methods computation
1 parent 1ed291b commit aa82f7b

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

stock_available/models/product_product.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,25 @@ class ProductProduct(models.Model):
2626

2727
@api.multi
2828
def _compute_available_quantities_dict(self):
29+
stock_dict = self._compute_quantities_dict(
30+
self._context.get('lot_id'),
31+
self._context.get('owner_id'),
32+
self._context.get('package_id'),
33+
self._context.get('from_date'),
34+
self._context.get('to_date'))
2935
res = {}
3036
for product in self:
3137
res[product.id] = {
32-
'immediately_usable_qty': product.virtual_available,
38+
'immediately_usable_qty': stock_dict[product.id][
39+
'virtual_available'],
3340
'potential_qty': 0.0
3441
}
35-
return res
42+
return res, stock_dict
3643

3744
@api.multi
3845
@api.depends('virtual_available')
3946
def _compute_available_quantities(self):
40-
res = self._compute_available_quantities_dict()
47+
res, _ = self._compute_available_quantities_dict()
4148
for product in self:
4249
for key, value in res[product.id].items():
4350
if hasattr(product, key):

stock_available/models/product_template.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def _compute_available_quantities(self):
3131

3232
@api.multi
3333
def _compute_available_quantities_dict(self):
34-
variants_dict = self.mapped(
34+
variants_dict, _ = self.mapped(
3535
'product_variant_ids')._compute_available_quantities_dict()
3636
res = {}
3737
for template in self:

0 commit comments

Comments
 (0)