From 31d4a2cc6f906c33f6a4f34d1fe2f5a081b57b18 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Mon, 27 Jan 2014 11:00:37 +0100 Subject: [PATCH] [IMP] product: in product.name_search(), do no search on variants (too costly) bzr revid: rco@openerp.com-20140127100037-t1hzbw0f4v8uys6f --- addons/product/product.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/product/product.py b/addons/product/product.py index 8d72e24b9ea..96fa4c6caa4 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -780,11 +780,11 @@ class product_product(osv.osv): # on a database with thousands of matching products, due to the huge merge+unique needed for the # OR operator (and given the fact that the 'name' lookup results come from the ir.translation table # Performing a quick memory merge of ids in Python will give much better performance - ids = set() - ids.update(self.search(cr, user, args + ['|',('default_code',operator,name),('variants',operator,name)], limit=limit, context=context)) + ids = set(self.search(cr, user, args + [('default_code', operator, name)], limit=limit, context=context)) if not limit or len(ids) < limit: # we may underrun the limit because of dupes in the results, that's fine - ids.update(self.search(cr, user, args + [('name',operator,name)], limit=(limit and (limit-len(ids)) or False) , context=context)) + limit2 = (limit - len(ids)) if limit else False + ids.update(self.search(cr, user, args + [('name', operator, name)], limit=limit2, context=context)) ids = list(ids) if not ids: ptrn = re.compile('(\[(.*?)\])')