From 5b2f13abdfed218db9098325061cd6b14eac0d3c Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Fri, 14 Nov 2014 13:40:02 +0100 Subject: [PATCH] [FIX] product: more accurate name_search First, name_search searches on default_code, then, if the limit is not reached, it searches on the product name The results found from the default code search must be removed from the search domain when doing the search on the product name, to avoid having results already found by the search on the default_code opw-618015 --- addons/product/product.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/product/product.py b/addons/product/product.py index b70fa030dd0..ce5b9bacddf 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -691,7 +691,7 @@ class product_product(osv.osv): ids.update(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)) + ids.update(self.search(cr, user, args + [('name',operator,name), ('id', 'not in', list(ids))], limit=(limit and (limit-len(ids)) or False) , context=context)) ids = list(ids) elif not ids and operator in expression.NEGATIVE_TERM_OPERATORS: ids = self.search(cr, user, args + ['&', ('default_code', operator, name), ('name', operator, name)], limit=limit, context=context)