[FIX] website: Handle matching words with point or slash

Fix an issue where products with internal references containing point
or slash were not recognized as direct matches in the website searchbar.
Instead, fuzzy search was used to find similar words.

This commit addresses the problem by fixing the regular expression
used for matching words in Odoo's search functionality.

X-original-commit: dee84ff3b0ec56149780e6eefb8724f954918fd1
Part-of: odoo/odoo#124211
This commit is contained in:
Mohamed Lamine LALMI
2023-06-08 09:10:01 +02:00
parent c056f858fd
commit 21972a122b
+2 -2
View File
@@ -1661,7 +1661,7 @@ class Website(models.Model):
:param limit: maximum number of records fetched per model to build the word list
:return: yields words
"""
match_pattern = r'[\w-]{%s,}' % min(4, len(search) - 3)
match_pattern = r'[\w./-]{%s,}' % min(4, len(search) - 3)
similarity_threshold = 0.3
lang = self.env.lang or 'en_US'
for search_detail in search_details:
@@ -1771,7 +1771,7 @@ class Website(models.Model):
:param limit: maximum number of records fetched per model to build the word list
:return: yields words
"""
match_pattern = r'[\w-]{%s,}' % min(4, len(search) - 3)
match_pattern = r'[\w./-]{%s,}' % min(4, len(search) - 3)
first = escape_psql(search[0])
for search_detail in search_details:
model_name, fields = search_detail['model'], search_detail['search_fields']