diff --git a/trytond/tests/test_tools.py b/trytond/tests/test_tools.py index 58a32a89f7..8fd1433ad1 100644 --- a/trytond/tests/test_tools.py +++ b/trytond/tests/test_tools.py @@ -540,6 +540,11 @@ class DomainInversionTestCase(unittest.TestCase): self.assertTrue(eval_domain(domain, {'x': [3]})) self.assertTrue(eval_domain(domain, {'x': [3, 4]})) self.assertFalse(eval_domain(domain, {'x': [1, 2]})) + self.assertFalse(eval_domain(domain, {'x': None})) + + domain = [['x', 'in', [1, None]]] + self.assertTrue(eval_domain(domain, {'x': None})) + self.assertFalse(eval_domain(domain, {'x': 2})) domain = [['x', 'not in', [3, 5]]] self.assertFalse(eval_domain(domain, {'x': 3})) @@ -547,6 +552,11 @@ class DomainInversionTestCase(unittest.TestCase): self.assertFalse(eval_domain(domain, {'x': [3]})) self.assertFalse(eval_domain(domain, {'x': [3, 4]})) self.assertTrue(eval_domain(domain, {'x': [1, 2]})) + self.assertFalse(eval_domain(domain, {'x': None})) + + domain = [['x', 'not in', [1, None]]] + self.assertFalse(eval_domain(domain, {'x': None})) + self.assertTrue(eval_domain(domain, {'x': 2})) domain = [['x', 'like', 'abc']] self.assertTrue(eval_domain(domain, {'x': 'abc'})) diff --git a/trytond/tools/domain_inversion.py b/trytond/tools/domain_inversion.py index 9c88530496..f68662eaee 100644 --- a/trytond/tools/domain_inversion.py +++ b/trytond/tools/domain_inversion.py @@ -96,7 +96,10 @@ def eval_leaf(part, context, boolop=operator.and_): return bool(context.get(field.split('.')[0])) context_field = context.get(field) if (operand not in {'=', '!='} - and (context_field is None or value is None)): + and (context_field is None or value is None) + and not (operand in {'in', 'not in'} + and context_field is None + and (isinstance(value, (list, tuple)) and None in value))): return if isinstance(context_field, datetime.date) and not value: if isinstance(context_field, datetime.datetime):