From 08dc76405ec179d7ae699c564f775c39b78e55ed Mon Sep 17 00:00:00 2001 From: "Laurent Mignon (ACSONE)" Date: Tue, 26 Sep 2017 18:09:34 +0200 Subject: [PATCH] [IMP] stock_available_unreserved: Improve perf in stock computation; Read quants without lang into the context to avoid sql join on ir.translations Iter on product with prefetch_fields=False and lang='' to avoid reading useless column ad join on ir.translations --- stock_available_unreserved/models/product.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stock_available_unreserved/models/product.py b/stock_available_unreserved/models/product.py index 87c039934..121a0f7ad 100644 --- a/stock_available_unreserved/models/product.py +++ b/stock_available_unreserved/models/product.py @@ -90,7 +90,7 @@ class ProductProduct(models.Model): domain_quant = self._prepare_domain_available_not_res(self) - quants = self.env['stock.quant'].read_group( + quants = self.env['stock.quant'].with_context(lang=False).read_group( domain_quant, ['product_id', 'location_id', 'qty'], ['product_id', 'location_id'], @@ -100,7 +100,7 @@ class ProductProduct(models.Model): # create a dictionary with the total value per products values_prod.setdefault(quant['product_id'][0], 0) values_prod[quant['product_id'][0]] += quant['qty'] - for product in self: + for product in self.with_context(prefetch_fields=False, lang=''): res[product.id] = {} # get total qty for the product qty = float_round(values_prod.get(product.id, 0.0),