[FIX] product: more accurate name_search
authorDenis Ledoux <dle@odoo.com>
Fri, 14 Nov 2014 12:40:02 +0000 (13:40 +0100)
committerDenis Ledoux <dle@odoo.com>
Fri, 14 Nov 2014 12:42:52 +0000 (13:42 +0100)
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

index b70fa03..ce5b9ba 100644 (file)
@@ -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)