diff --git a/addons/product/product.py b/addons/product/product.py index b6a58fcd1e8..27cd4249a60 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -657,9 +657,9 @@ class product_product(osv.osv): # 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)], limit=limit, context=context)) - if len(ids) < limit: + 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-len(ids)), context=context)) + ids.update(self.search(cr, user, args + [('name',operator,name)], limit=(limit and (limit-len(ids)) or False) , context=context)) ids = list(ids) if not ids: ptrn = re.compile('(\[(.*?)\])')