changeset 44c68ce98e8e in modules/purchase:default
details: https://hg.tryton.org/modules/purchase?cmd=changeset&node=44c68ce98e8e
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:
product.py | 21 +++++++++++----------
1 files changed, 11 insertions(+), 10 deletions(-)
diffs (42 lines):
diff -r 948fa4b0b33e -r 44c68ce98e8e product.py
--- a/product.py Thu Sep 15 21:47:26 2022 +0200
+++ b/product.py Fri Sep 16 23:37:38 2022 +0200
@@ -13,7 +13,7 @@
from trytond.modules.product import price_digits
from trytond.pool import Pool, PoolMeta
from trytond.pyson import Bool, Eval, If
-from trytond.tools import lstrip_wildcard
+from trytond.tools import is_full_text, lstrip_wildcard
from trytond.transaction import Transaction
from .exceptions import PurchaseUOMWarning
@@ -373,19 +373,20 @@
@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 = [bool_op,
- ('template',) + tuple(clause[1:]),
- ('product',) + tuple(clause[1:]),
- ('party',) + tuple(clause[1:]),
- ('code', clause[1], code_value) + tuple(clause[3:]),
- ('name',) + tuple(clause[1:]),
+ ('template', operator, operand, *extra),
+ ('product', operator, operand, *extra),
+ ('party', operator, operand, *extra),
+ ('code', operator, code_value, *extra),
+ ('name', operator, operand, *extra),
]
return domain