From 7e0c51aecbe6f9fe9efcafeeb5f099f8451d2033 Mon Sep 17 00:00:00 2001 From: Alexandre Fayolle Date: Mon, 26 Oct 2015 13:56:24 +0100 Subject: [PATCH] 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) --- stock_available_immediately/product.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/stock_available_immediately/product.py b/stock_available_immediately/product.py index c41e090b6..845ef63e7 100644 --- a/stock_available_immediately/product.py +++ b/stock_available_immediately/product.py @@ -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