product_available improvements

* fix the dependencies for the computed field

* use api.multi instead of api.one to avoid calling
  super()._immediately_usable_qty in a loop (this improves perfs on a tree view
  display)
This commit is contained in:
Alexandre Fayolle
2015-10-26 13:56:24 +01:00
committed by Víctor Martínez
parent e5a878f1c5
commit 7e0c51aecb

View File

@@ -9,8 +9,10 @@ class Product(models.Model):
"""Subtract incoming qty from immediately_usable_qty"""
_inherit = 'product.product'
@api.multi
@api.depends('virtual_available', 'incoming_qty')
def _immediately_usable_qty(self):
"""Ignore the incoming goods in the quantity available to promise"""
super(Product, self)._immediately_usable_qty()
for product in self:
product.immediately_usable_qty -= product.incoming_qty
super(ProductProduct, self)._immediately_usable_qty()
for prod in self:
prod.immediately_usable_qty -= prod.incoming_qty