From 50132daa0ca8b671b970db7279bab8f3bf604a7e Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Thu, 11 Apr 2019 15:24:46 +0200 Subject: [PATCH] Remove starting wildcard when searching on codes and numbers issue7347 review64541002 --- CHANGELOG | 1 + product.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 4938cf576c..d1668fd5a7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Remove starting wildcard when searching on codes and numbers * Allow product supplier to be defined on variants Version 5.0.0 - 2018-10-01 diff --git a/product.py b/product.py index 58f7819b12..50c7b7297a 100644 --- a/product.py +++ b/product.py @@ -11,6 +11,7 @@ from trytond.model import ModelView, ModelSQL, MatchMixin, fields, \ from trytond.pyson import Eval, If, Bool from trytond.pool import Pool, PoolMeta from trytond.transaction import Transaction +from trytond.tools import lstrip_wildcard from trytond.modules.product import price_digits @@ -293,11 +294,14 @@ class ProductSupplier(sequence_ordered(), ModelSQL, ModelView, MatchMixin): 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',) + tuple(clause[1:]), + ('code', clause[1], code_value) + tuple(clause[3:]), ('name',) + tuple(clause[1:]), ] return domain