changeset 2986cf84725c in trytond:5.4
details: https://hg.tryton.org/trytond?cmd=changeset;node=2986cf84725c
description:
        Skip invalid branch of domain without the inverted field

        Those branches of the domain should not prevent to compute a proper 
inverted
        domain for the field as the other fields will be fixed later.

        issue9200
        review311191002
        (grafted from 33c9aaa152a6dfb4a92881f87f0201a67d5daa25)
diffstat:

 trytond/tests/test_tools.py       |  6 ++++--
 trytond/tools/domain_inversion.py |  2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)

diffs (35 lines):

diff -r d7772acbef89 -r 2986cf84725c trytond/tests/test_tools.py
--- a/trytond/tests/test_tools.py       Fri Apr 10 18:26:35 2020 +0200
+++ b/trytond/tests/test_tools.py       Sun Apr 12 23:21:08 2020 +0200
@@ -356,7 +356,8 @@
         self.assertEqual(domain_inversion(domain, 'z'), [['z', '=', 3]])
         self.assertEqual(
             domain_inversion(domain, 'z', {'x': 5}), [['z', '=', 3]])
-        self.assertFalse(domain_inversion(domain, 'z', {'x': 5, 'y': 5}))
+        self.assertEqual(
+            domain_inversion(domain, 'z', {'x': 5, 'y': 5}), [['z', '=', 3]])
         self.assertEqual(
             domain_inversion(domain, 'z', {'x': 5, 'y': 7}), [['z', '=', 3]])
 
@@ -365,7 +366,8 @@
         self.assertEqual(domain_inversion(domain, 'z'), [['z', '=', 3]])
         self.assertEqual(
             domain_inversion(domain, 'z', {'x': 5}), [['z', '=', 3]])
-        self.assertFalse(domain_inversion(domain, 'z', {'y': 5}))
+        self.assertEqual(
+            domain_inversion(domain, 'z', {'y': 5}), [['z', '=', 3]])
         self.assertEqual(
             domain_inversion(domain, 'z', {'x': 4, 'y': 7}), [['z', '=', 3]])
 
diff -r d7772acbef89 -r 2986cf84725c trytond/tools/domain_inversion.py
--- a/trytond/tools/domain_inversion.py Fri Apr 10 18:26:35 2020 +0200
+++ b/trytond/tools/domain_inversion.py Sun Apr 12 23:21:08 2020 +0200
@@ -340,6 +340,8 @@
             if isinstance(part, And):
                 part_inversion = part.inverse(symbol, context)
                 evaluated = isinstance(part_inversion, bool)
+                if symbol not in part.variables:
+                    continue
                 if not evaluated:
                     result.append(part_inversion)
                 elif part_inversion:

Reply via email to