changeset 3a9d487cdf99 in modules/sale_product_customer:default
details:
https://hg.tryton.org/modules/sale_product_customer?cmd=changeset&node=3a9d487cdf99
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 | 24 ++++++++++++------------
1 files changed, 12 insertions(+), 12 deletions(-)
diffs (45 lines):
diff -r 68ad207b6db0 -r 3a9d487cdf99 product.py
--- a/product.py Sat Jul 09 23:17:58 2022 +0200
+++ b/product.py Fri Sep 16 23:37:38 2022 +0200
@@ -6,7 +6,7 @@
sequence_ordered)
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
class ProductCustomer(
@@ -55,21 +55,21 @@
@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])
- 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:]),
+ code_value = operand
+ if operator.endswith('like') and is_full_text(operand):
+ code_value = lstrip_wildcard(operand)
+ return [bool_op,
+ ('template', operator, operand, *extra),
+ ('product', operator, operand, *extra),
+ ('party', operator, operand, *extra),
+ ('code', operator, code_value, *extra),
+ ('name', operator, operand, *extra),
]
- return domain
class Template(metaclass=PoolMeta):