diff --git a/trytond/trytond/model/match.py b/trytond/trytond/model/match.py index 4b168828f5..bdbbf00828 100644 --- a/trytond/trytond/model/match.py +++ b/trytond/trytond/model/match.py @@ -11,6 +11,8 @@ class MatchMixin(object): and matching value as value''' for field_name, pattern_value in pattern.items(): value = getattr(self, field_name) + if value == '': + value = None if not match_none and value is None: continue field = self._fields[field_name] diff --git a/trytond/trytond/tests/test_model_match.py b/trytond/trytond/tests/test_model_match.py index 39ce043573..82bf3bc32d 100644 --- a/trytond/trytond/tests/test_model_match.py +++ b/trytond/trytond/tests/test_model_match.py @@ -35,7 +35,9 @@ class ModelMatchMixinTestCase(TestCase): (Model(f=(fields.Char("F"), 'foo')), {'f': 'bar'}, False), (Model(f=(fields.Char("F"), 'foo')), {'f': None}, False), (Model(f=(fields.Char("F"), None)), {'f': 'foo'}, True), + (Model(f=(fields.Char("F"), '')), {'f': 'foo'}, True), (Model(f=(fields.Char("F"), None)), {'f': None}, True), + (Model(f=(fields.Char("F"), '')), {'f': None}, True), ]: with self.subTest(record=record, pattern=pattern): self.assertEqual(record.match(pattern), result) @@ -47,7 +49,9 @@ class ModelMatchMixinTestCase(TestCase): (Model(f=(fields.Char("F"), 'foo')), {'f': 'bar'}, False), (Model(f=(fields.Char("F"), 'foo')), {'f': None}, False), (Model(f=(fields.Char("F"), None)), {'f': 'foo'}, False), + (Model(f=(fields.Char("F"), '')), {'f': 'foo'}, False), (Model(f=(fields.Char("F"), None)), {'f': None}, True), + (Model(f=(fields.Char("F"), '')), {'f': None}, True), ]: with self.subTest(record=record, pattern=pattern): self.assertEqual(