From b02a85fcf18e8d44c41ae43726728bf3029d7a49 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Sun, 21 Aug 2016 17:13:26 -0700 Subject: [PATCH] [FIX] product: avoid search returning two times the same product --- addons/product/models/product.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/addons/product/models/product.py b/addons/product/models/product.py index 94f6d50a7bd..221a62595c2 100644 --- a/addons/product/models/product.py +++ b/addons/product/models/product.py @@ -422,11 +422,7 @@ class ProductProduct(models.Model): # 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 - products = self.search(args + [('default_code', operator, name)], limit=limit) - if not limit or len(products) < limit: - # we may underrun the limit because of dupes in the results, that's fine - limit2 = (limit - len(products)) if limit else False - products += self.search(args + [('name', operator, name), ('id', 'not in', self.ids)], limit=limit2) + products = self.search(args + ['|', ('default_code', operator, name), ('name', operator, name)], limit=limit) elif not products and operator in expression.NEGATIVE_TERM_OPERATORS: products = self.search(args + ['&', ('default_code', operator, name), ('name', operator, name)], limit=limit) if not products and operator in positive_operators: