changeset 76099fe283b7 in modules/party:default
details: https://hg.tryton.org/modules/party?cmd=changeset&node=76099fe283b7
description:
        Left strip code operand only when it is a full text

        This allow to write query with double wildcard to force a full text 
search on
        the code.

        issue11682
        review443571003
diffstat:

 party.py |  19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)

diffs (40 lines):

diff -r de95a246129a -r 76099fe283b7 party.py
--- a/party.py  Tue Sep 13 00:16:27 2022 +0200
+++ b/party.py  Fri Sep 16 23:37:38 2022 +0200
@@ -14,7 +14,7 @@
 from trytond.model.exceptions import AccessError
 from trytond.pool import Pool
 from trytond.pyson import Bool, Eval
-from trytond.tools import lstrip_wildcard
+from trytond.tools import is_full_text, lstrip_wildcard
 from trytond.tools.multivalue import migrate_property
 from trytond.transaction import Transaction
 from trytond.wizard import Button, StateTransition, StateView, Wizard
@@ -295,18 +295,19 @@
 
     @classmethod
     def search_rec_name(cls, name, clause):
-        if clause[1].startswith('!') or clause[1].startswith('not '):
+        _, operator, operand, *extra = clause
+        if operator.startswith('!') or operator.startswith('not '):
             bool_op = 'AND'
         else:
             bool_op = 'OR'
-        code_value = clause[2]
-        if clause[1].endswith('like'):
-            code_value = lstrip_wildcard(clause[2])
+        code_value = operand
+        if operator.endswith('like') and is_full_text(operand):
+            code_value = lstrip_wildcard(operand)
         return [bool_op,
-            ('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:]),
+            ('code', operator, code_value, *extra),
+            ('identifiers.code', operator, code_value, *extra),
+            ('name', operator, operand, *extra),
+            ('contact_mechanisms.rec_name', operator, operand, *extra),
             ]
 
     def address_get(self, type=None):

Reply via email to