changeset 49b3b3575f13 in trytond:5.4
details: https://hg.tryton.org/trytond?cmd=changeset;node=49b3b3575f13
description:
Do not force value in OR-ed clause
When any other variable in Or-ed clause is not known, we can not force
the
value of the variable.
issue9092
review272941002
(grafted from bb494c884ebd4f70ee5efb497399bcc5e3737d95)
diffstat:
trytond/tests/test_tools.py | 13 ++++++-------
trytond/tools/domain_inversion.py | 5 ++---
2 files changed, 8 insertions(+), 10 deletions(-)
diffs (57 lines):
diff -r e61076f1df5d -r 49b3b3575f13 trytond/tests/test_tools.py
--- a/trytond/tests/test_tools.py Mon Mar 09 18:29:19 2020 +0100
+++ b/trytond/tests/test_tools.py Fri Mar 06 23:14:24 2020 +0100
@@ -313,9 +313,8 @@
def test_or_inversion(self):
domain = ['OR', ['x', '=', 3], ['y', '>', 5], ['z', '=', 'abc']]
- self.assertEqual(domain_inversion(domain, 'x'), [['x', '=', 3]])
- self.assertEqual(
- domain_inversion(domain, 'x', {'y': 4}), [['x', '=', 3]])
+ self.assertEqual(domain_inversion(domain, 'x'), True)
+ self.assertEqual(domain_inversion(domain, 'x', {'y': 4}), True)
self.assertEqual(
domain_inversion(domain, 'x', {'y': 4, 'z': 'ab'}),
[['x', '=', 3]])
@@ -332,22 +331,22 @@
self.assertTrue(domain_inversion(domain, 'z'))
domain = ['OR', ['x.id', '>', 5], ['y', '<', 3]]
- self.assertEqual(domain_inversion(domain, 'y'), [['y', '<', 3]])
+ self.assertEqual(domain_inversion(domain, 'y'), True)
self.assertEqual(
- domain_inversion(domain, 'y', {'z': 4}), [['y', '<', 3]])
+ domain_inversion(domain, 'y', {'z': 4}), True)
self.assertTrue(domain_inversion(domain, 'y', {'x': 3}))
domain = ['OR', ['length', '>', 5], ['language.code', '=', 'de_DE']]
self.assertEqual(
domain_inversion(domain, 'length', {'length': 0, 'name': 'n'}),
- [['length', '>', 5]])
+ True)
def test_orand_inversion(self):
domain = ['OR', [['x', '=', 3], ['y', '>', 5], ['z', '=', 'abc']],
[['x', '=', 4]], [['y', '>', 6]]]
self.assertTrue(domain_inversion(domain, 'x'))
self.assertEqual(
- domain_inversion(domain, 'x', {'y': 4}), [[['x', '=', 4]]])
+ domain_inversion(domain, 'x', {'y': 4}), True)
self.assertTrue(domain_inversion(domain, 'x', {'z': 'abc', 'y': 7}))
self.assertTrue(domain_inversion(domain, 'x', {'y': 7}))
self.assertTrue(domain_inversion(domain, 'x', {'z': 'ab'}))
diff -r e61076f1df5d -r 49b3b3575f13 trytond/tools/domain_inversion.py
--- a/trytond/tools/domain_inversion.py Mon Mar 09 18:29:19 2020 +0100
+++ b/trytond/tools/domain_inversion.py Fri Mar 06 23:14:24 2020 +0100
@@ -370,9 +370,8 @@
def inverse(self, symbol, context):
result = []
known_variables = set(context.keys())
- if (symbol not in self.variables
- and not known_variables >= self.variables):
- # In this case we don't know anything about this OR part, we
+ if not known_variables >= (self.variables - {symbol}):
+ # In this case we don't know enough about this OR part, we
# consider it to be True (because people will have the constraint
# on this part later).
return True