changeset e455de0a2feb in modules/account_payment_sepa:default
details:
https://hg.tryton.org/modules/account_payment_sepa?cmd=changeset&node=e455de0a2feb
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:
payment.py | 43 ++++++++++++++++++++-----------------------
1 files changed, 20 insertions(+), 23 deletions(-)
diffs (73 lines):
diff -r 6e6dabfb679d -r e455de0a2feb payment.py
--- a/payment.py Tue Jun 21 08:31:41 2022 +0200
+++ b/payment.py Fri Sep 16 23:37:38 2022 +0200
@@ -25,7 +25,7 @@
from trytond.pool import Pool, PoolMeta
from trytond.pyson import Eval, If
from trytond.tools import (
- grouped_slice, lstrip_wildcard, reduce_ids, sortable_values)
+ grouped_slice, is_full_text, lstrip_wildcard, reduce_ids, sortable_values)
from trytond.transaction import Transaction
from .sepa_handler import CAMT054
@@ -307,18 +307,18 @@
@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)
domain = super().search_rec_name(name, clause)
- return [
- bool_op,
+ return [bool_op,
domain,
- ('sepa_id', clause[1], code_value) + tuple(clause[3:]),
+ ('sepa_id', operator, code_value, *extra),
]
@@ -447,22 +447,19 @@
@classmethod
def search_rec_name(cls, name, clause):
+ _, operator, operand, *extra = clause
+ if operator.startswith('!') or operator.startswith('not '):
+ bool_op = 'AND'
+ else:
+ bool_op = 'OR'
+ code_value = operand
+ if operator.endswith('like') and is_full_text(operand):
+ code_value = lstrip_wildcard(operand)
domain = super().search_rec_name(name, clause)
- if domain:
- if clause[1].startswith('!') or clause[1].startswith('not '):
- bool_op = 'AND'
- else:
- bool_op = 'OR'
- domain = [
- bool_op,
- domain,
- ]
- code_value = clause[2]
- if clause[1].endswith('like'):
- code_value = lstrip_wildcard(clause[2])
- domain.append(
- ('sepa_info_id', clause[1], code_value) + tuple(clause[3:]))
- return domain
+ return [bool_op,
+ domain,
+ ('sepa_info_id', operator, code_value, *extra),
+ ]
class Mandate(Workflow, ModelSQL, ModelView):