From 942d8a2c3f15cf3b4fa902c686d5a4a97685a41b Mon Sep 17 00:00:00 2001 From: Florent de Labarre Date: Mon, 13 Feb 2017 17:23:59 +0100 Subject: [PATCH] [FIX] product: complete name_search The name_search was not working properly if limit=None is specified (e.g. searching for the search bar on a many2one field to product.template). As `any int > None` is true, the condition is always validated as soon as the search returns at least one result. The product.product search has no limit parameter and use the default 100. If the 100 first products have only a few templates (a lot of variants), the result will be incomplete as stopping after the first iteration. Closes #15477 --- addons/product/models/product_template.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/product/models/product_template.py b/addons/product/models/product_template.py index ef0f698424b..43d34f65c8c 100644 --- a/addons/product/models/product_template.py +++ b/addons/product/models/product_template.py @@ -322,7 +322,7 @@ class ProductTemplate(models.Model): products_ns = Product.name_search(name, args+domain, operator=operator) products = Product.browse([x[0] for x in products_ns]) templates |= products.mapped('product_tmpl_id') - if (not products) or (len(templates) > limit): + if (not products) or (limit and (len(templates) > limit)): break # re-apply product.template order + name_get