changeset ffedd8c5b4cc in modules/account:default
details: https://hg.tryton.org/modules/account?cmd=changeset&node=ffedd8c5b4cc
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 | 16 +++++++++-------
journal.py | 16 +++++++++-------
tax.py | 15 ++++++++-------
3 files changed, 26 insertions(+), 21 deletions(-)
diffs (110 lines):
diff -r efff41558856 -r ffedd8c5b4cc account.py
--- a/account.py Wed Sep 14 19:27:27 2022 +0200
+++ b/account.py Fri Sep 16 23:37:38 2022 +0200
@@ -21,7 +21,8 @@
from trytond.pool import Pool
from trytond.pyson import Bool, Eval, If, PYSONEncoder
from trytond.report import Report
-from trytond.tools import grouped_slice, lstrip_wildcard, reduce_ids
+from trytond.tools import (
+ grouped_slice, is_full_text, lstrip_wildcard, reduce_ids)
from trytond.transaction import Transaction
from trytond.wizard import (
Button, StateAction, StateTransition, StateView, Wizard)
@@ -619,16 +620,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),
]
@staticmethod
diff -r efff41558856 -r ffedd8c5b4cc journal.py
--- a/journal.py Wed Sep 14 19:27:27 2022 +0200
+++ b/journal.py Fri Sep 16 23:37:38 2022 +0200
@@ -14,7 +14,8 @@
from trytond.modules.currency.fields import Monetary
from trytond.pool import Pool
from trytond.pyson import Bool, Eval, Id
-from trytond.tools import grouped_slice, lstrip_wildcard, reduce_ids
+from trytond.tools import (
+ grouped_slice, is_full_text, lstrip_wildcard, reduce_ids)
from trytond.tools.multivalue import migrate_property
from trytond.transaction import Transaction
@@ -74,16 +75,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),
]
@classmethod
diff -r efff41558856 -r ffedd8c5b4cc tax.py
--- a/tax.py Wed Sep 14 19:27:27 2022 +0200
+++ b/tax.py Fri Sep 16 23:37:38 2022 +0200
@@ -18,7 +18,7 @@
from trytond.modules.currency.fields import Monetary
from trytond.pool import Pool
from trytond.pyson import Bool, Eval, If, PYSONEncoder
-from trytond.tools import cursor_dict, lstrip_wildcard
+from trytond.tools import cursor_dict, is_full_text, lstrip_wildcard
from trytond.transaction import Transaction
from trytond.wizard import Button, StateAction, StateView, Wizard
@@ -220,16 +220,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),
]
@classmethod