changeset 51728a362a93 in modules/country:default details: https://hg.tryton.org/modules/country?cmd=changeset;node=51728a362a93 description: Remove starting wildcard when searching on codes and numbers
issue7347 review64541002 diffstat: CHANGELOG | 1 + country.py | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diffs (37 lines): diff -r b77d09bfc14e -r 51728a362a93 CHANGELOG --- a/CHANGELOG Sun Apr 07 19:50:03 2019 +0200 +++ b/CHANGELOG Thu Apr 11 15:21:02 2019 +0200 @@ -1,3 +1,4 @@ +* Remove starting wildcard when searching on codes and numbers * Add active field on country and subdivision Version 5.0.0 - 2018-10-01 diff -r b77d09bfc14e -r 51728a362a93 country.py --- a/country.py Sun Apr 07 19:50:03 2019 +0200 +++ b/country.py Thu Apr 11 15:21:02 2019 +0200 @@ -2,6 +2,7 @@ # this repository contains the full copyright notices and license terms. from trytond.model import ModelView, ModelSQL, DeactivableMixin, fields from trytond.pyson import Eval +from trytond.tools import lstrip_wildcard __all__ = ['Country', 'Subdivision', 'Zip'] @@ -40,11 +41,14 @@ @classmethod def search_rec_name(cls, name, clause): + code_value = clause[2] + if clause[1].endswith('like'): + code_value = lstrip_wildcard(clause[2]) return ['OR', ('name',) + tuple(clause[1:]), - ('code',) + tuple(clause[1:]), - ('code3',) + tuple(clause[1:]), - ('code_numeric',) + tuple(clause[1:]), + ('code', clause[1], code_value) + tuple(clause[3:]), + ('code3', clause[1], code_value) + tuple(clause[3:]), + ('code_numeric', clause[1], code_value) + tuple(clause[3:]), ] @classmethod