changeset 2b7bdcc660a3 in modules/party:default
details: https://hg.tryton.org/modules/party?cmd=changeset;node=2b7bdcc660a3
description:
        Remove starting wildcard when searching on codes and numbers

        issue7347
        review64541002
diffstat:

 CHANGELOG |  1 +
 party.py  |  8 ++++++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diffs (34 lines):

diff -r 06e43a87e89f -r 2b7bdcc660a3 CHANGELOG
--- a/CHANGELOG Mon Apr 08 10:10:40 2019 +0200
+++ b/CHANGELOG Thu Apr 11 15:23:59 2019 +0200
@@ -1,3 +1,4 @@
+* Remove starting wildcard when searching on codes and numbers
 * Include all identifier from python-stdnum
 * Use country code as local prefix to parse phone numbers
 
diff -r 06e43a87e89f -r 2b7bdcc660a3 party.py
--- a/party.py  Mon Apr 08 10:10:40 2019 +0200
+++ b/party.py  Thu Apr 11 15:23:59 2019 +0200
@@ -14,6 +14,7 @@
 from trytond.pool import Pool
 from trytond import backend
 from trytond.tools.multivalue import migrate_property
+from trytond.tools import lstrip_wildcard
 from .exceptions import (
     InvalidIdentifierCode, VIESUnavailable, SimilarityWarning, EraseError)
 
@@ -220,9 +221,12 @@
             bool_op = 'AND'
         else:
             bool_op = 'OR'
+        code_value = clause[2]
+        if clause[1].endswith('like'):
+            code_value = lstrip_wildcard(clause[2])
         return [bool_op,
-            ('code',) + tuple(clause[1:]),
-            ('identifiers.code',) + tuple(clause[1:]),
+            ('code', clause[1], code_value) + tuple(clause[3:]),
+            ('identifiers.code', clause[1], code_value) + tuple(clause[3:]),
             ('name',) + tuple(clause[1:]),
             ('contact_mechanisms.rec_name',) + tuple(clause[1:]),
             ]

Reply via email to