From 3076d7e46435fb1932f0e79666d8aedf78019d48 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Thu, 31 Jan 2019 13:30:27 +0000 Subject: [PATCH] [FIX] base: partner search no alnum->no VAT match MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When we search a partner, there is a system that show partner who match exactly the searched term with non-alphanumeric character removed. But since a6e1eb9f0a there is an issue that wrong partner match if: - they have an empty string as VAT in the database (odd but can happen) - if the searched term only contains non-alphanumberic characters eg. i search 'é' -> all partner with empty string vat are found since the empty search '' matches empty VAT '' With this changeset, if there is no alphanumeric character we will check depending on the operator `vat=NULL`, `vat like NULL`, `vat ilike NULL` that all will not match any result (and in the query plan does not take time). opw-1929563 closes #30732 --- odoo/addons/base/models/res_partner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odoo/addons/base/models/res_partner.py b/odoo/addons/base/models/res_partner.py index f717f32f413..6a28f10151b 100644 --- a/odoo/addons/base/models/res_partner.py +++ b/odoo/addons/base/models/res_partner.py @@ -712,7 +712,7 @@ class Partner(models.Model): vat=unaccent('res_partner.vat'),) where_clause_params += [search_name]*3 # for email / display_name, reference - where_clause_params += [re.sub('[^a-zA-Z0-9]+', '', search_name)] # for vat + where_clause_params += [re.sub('[^a-zA-Z0-9]+', '', search_name) or None] # for vat where_clause_params += [search_name] # for order by if limit: query += ' limit %s'