[10.0][CHG]stock_available...: improve stock methods computation

This commit is contained in:
Cédric Pigeon
2018-09-03 16:05:00 +02:00
committed by Florian da Costa
parent bfc9400e46
commit 6a4c3950dc
2 changed files with 11 additions and 4 deletions

View File

@@ -26,18 +26,25 @@ class ProductProduct(models.Model):
@api.multi
def _compute_available_quantities_dict(self):
stock_dict = self._compute_quantities_dict(
self._context.get('lot_id'),
self._context.get('owner_id'),
self._context.get('package_id'),
self._context.get('from_date'),
self._context.get('to_date'))
res = {}
for product in self:
res[product.id] = {
'immediately_usable_qty': product.virtual_available,
'immediately_usable_qty': stock_dict[product.id][
'virtual_available'],
'potential_qty': 0.0
}
return res
return res, stock_dict
@api.multi
@api.depends('virtual_available')
def _compute_available_quantities(self):
res = self._compute_available_quantities_dict()
res, _ = self._compute_available_quantities_dict()
for product in self:
for key, value in res[product.id].items():
if hasattr(product, key):

View File

@@ -31,7 +31,7 @@ class ProductTemplate(models.Model):
@api.multi
def _compute_available_quantities_dict(self):
variants_dict = self.mapped(
variants_dict, _ = self.mapped(
'product_variant_ids')._compute_available_quantities_dict()
res = {}
for template in self: