From f975cefcb8031f4d80ec43e1d2f09a6741187c2f Mon Sep 17 00:00:00 2001 From: Ludovic Laffineur lla Date: Mon, 11 Jan 2016 10:17:03 +0100 Subject: [PATCH] [FIX] Improve performance of the scheduler. This commit improves performances of the scheduler when the database is big (lots of products with lots of fields). This avoids prefetching all the fields for every 1000 products while we only use 2 of them. --- addons/stock/product.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/stock/product.py b/addons/stock/product.py index 21e5512383d..2e7b8a6a2ec 100644 --- a/addons/stock/product.py +++ b/addons/stock/product.py @@ -169,7 +169,9 @@ class product_product(osv.osv): moves_in = dict(map(lambda x: (x['product_id'][0], x['product_qty']), moves_in)) moves_out = dict(map(lambda x: (x['product_id'][0], x['product_qty']), moves_out)) res = {} - for product in self.browse(cr, uid, ids, context=context): + ctx = context.copy() + ctx.update({'prefetch_fields': False}) + for product in self.browse(cr, uid, ids, context=ctx): id = product.id qty_available = float_round(quants.get(id, 0.0), precision_rounding=product.uom_id.rounding) incoming_qty = float_round(moves_in.get(id, 0.0), precision_rounding=product.uom_id.rounding)