mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[10.0][CHG]stock_available...: improve stock methods computation
This commit is contained in:
committed by
Florian da Costa
parent
bfc9400e46
commit
6a4c3950dc
@@ -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):
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user