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
This commit is contained in:
1 parent
dd50039c04
commit
f0559e37fb
3 files changed
+26
-21
No files matched your search
+9
-7
@@ -21,7 +21,8 @@ from trytond.modules.currency.fields import Monetary
|
||||
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 @@ def AccountMixin(template=False):
|
||||
|
||||
@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
|
||||
|
||||
+9
-7
@@ -14,7 +14,8 @@ from trytond.modules.company.model import (
|
||||
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 @@ class Journal(
|
||||
|
||||
@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
|
||||
|
||||
@@ -18,7 +18,7 @@ from trytond.model.exceptions import AccessError
|
||||
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 @@ class TaxCode(
|
||||
|
||||
@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
|
||||
|
||||
Reference in new issue
Block a user