changeset ab59016bfe86 in modules/analytic_account:default
details: 
https://hg.tryton.org/modules/analytic_account?cmd=changeset&node=ab59016bfe86
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:

 account.py |  15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diffs (36 lines):

diff -r efc1da9c6cff -r ab59016bfe86 account.py
--- a/account.py        Mon Jul 18 00:04:04 2022 +0200
+++ b/account.py        Fri Sep 16 23:37:38 2022 +0200
@@ -14,7 +14,7 @@
 from trytond.modules.currency.fields import Monetary
 from trytond.pool import Pool
 from trytond.pyson import Eval, If, PYSONDecoder, PYSONEncoder
-from trytond.tools import lstrip_wildcard
+from trytond.tools import is_full_text, lstrip_wildcard
 from trytond.transaction import Transaction
 
 from .exceptions import AccountValidationError
@@ -258,16 +258,17 @@
 
     @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:]),
-            (cls._rec_name,) + tuple(clause[1:]),
+            ('code', operator, code_value, *extra),
+            (cls._rec_name, operator, operand, *extra),
             ]
 
     def distribute(self, amount):

Reply via email to