From f64746533296d6a276a5879115047d730f3d6315 Mon Sep 17 00:00:00 2001 From: Mylyna Hy Date: Wed, 1 Mar 2023 23:11:55 +0000 Subject: [PATCH] [FIX] website_sale: improve internal ref search Problem: Results do not show when users search the internal reference of the product template on the ecommerce page if the product has other variants aside from itself. The search only searches internal reference of product variants and not the product template. Steps to reproduce on Runbot 15: - Install Sales and eCommerce - Create a product (can be sold), Set its Internal reference, and Add attributes and variants to the product --> Save Note: the internal ref of the product variants are not set by default - Go to ecommerce webpage and search the internal reference --> no product found Proposed solution: Add a condition to the domain to also search based on the internal reference of the product template opw-3212883 closes odoo/odoo#116771 X-original-commit: 5f0578059fe436d770e38ca90d8311ee80301878 Signed-off-by: Antoine Vandevenne (anv) --- addons/website_sale/models/product_template.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/website_sale/models/product_template.py b/addons/website_sale/models/product_template.py index 682e74cf7fc..aee408e68b6 100644 --- a/addons/website_sale/models/product_template.py +++ b/addons/website_sale/models/product_template.py @@ -467,10 +467,11 @@ class ProductTemplate(models.Model): ids = [value[1]] if attrib: domains.append([('attribute_line_ids.value_ids', 'in', ids)]) - search_fields = ['name', 'product_variant_ids.default_code'] + search_fields = ['name', 'default_code', 'product_variant_ids.default_code'] fetch_fields = ['id', 'name', 'website_url'] mapping = { 'name': {'name': 'name', 'type': 'text', 'match': True}, + 'default_code': {'name': 'default_code', 'type': 'text', 'match': True}, 'product_variant_ids.default_code': {'name': 'product_variant_ids.default_code', 'type': 'text', 'match': True}, 'website_url': {'name': 'website_url', 'type': 'text', 'truncate': False}, }