summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--addons/product/models/product.py7
-rw-r--r--addons/product/tests/test_variants.py9
2 files changed, 15 insertions, 1 deletions
diff --git a/addons/product/models/product.py b/addons/product/models/product.py
index 3f50ffef7cb..2dce8e9fa36 100644
--- a/addons/product/models/product.py
+++ b/addons/product/models/product.py
@@ -431,7 +431,12 @@ class ProductProduct(models.Model):
limit2 = (limit - len(products)) if limit else False
products += self.search(args + [('name', operator, name), ('id', 'not in', products.ids)], limit=limit2)
elif not products and operator in expression.NEGATIVE_TERM_OPERATORS:
- products = self.search(args + ['&', ('default_code', operator, name), ('name', operator, name)], limit=limit)
+ domain = expression.OR([
+ ['&', ('default_code', operator, name), ('name', operator, name)],
+ ['&', ('default_code', '=', False), ('name', operator, name)],
+ ])
+ domain = expression.AND([args, domain])
+ products = self.search(domain, limit=limit)
if not products and operator in positive_operators:
ptrn = re.compile('(\[(.*?)\])')
res = ptrn.search(name)
diff --git a/addons/product/tests/test_variants.py b/addons/product/tests/test_variants.py
index 7917a0d4a2b..804bbc55c95 100644
--- a/addons/product/tests/test_variants.py
+++ b/addons/product/tests/test_variants.py
@@ -40,6 +40,15 @@ class TestVariantsSearch(TransactionCase):
self.assertIn(self.product_shirt_template, search_value,
'Shirt should be found searching L')
+ def test_name_search(self):
+ self.product_slip_template = self.env['product.template'].create({
+ 'name': 'Slip',
+ })
+ res = self.env['product.product'].name_search('Shirt', [], 'not ilike', None)
+ res_ids = [r[0] for r in res]
+ self.assertIn(self.product_slip_template.product_variant_ids.id, res_ids,
+ 'Slip should be found searching \'not ilike\'')
+
class TestVariants(common.TestProductCommon):