details:   https://code.tryton.org/tryton/commit/7a8606077f4c
branch:    default
user:      Cédric Krier <[email protected]>
date:      Mon Jan 19 16:40:01 2026 +0100
description:
        Support clause on multiselection field with operator in and value None

        Closes #14520
diffstat:

 trytond/trytond/model/fields/multiselection.py     |   4 ++-
 trytond/trytond/tests/test_field_multiselection.py |  24 ++++++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletions(-)

diffs (48 lines):

diff -r 550efceff67d -r 7a8606077f4c 
trytond/trytond/model/fields/multiselection.py
--- a/trytond/trytond/model/fields/multiselection.py    Wed Jan 28 15:58:01 
2026 +0100
+++ b/trytond/trytond/model/fields/multiselection.py    Mon Jan 19 16:40:01 
2026 +0100
@@ -92,7 +92,9 @@
         database = Transaction().database
         table, _ = tables[None]
         raw_column = self.sql_column(table)
-        if isinstance(value, str):
+        if value is None:
+            expression = Literal(False)
+        elif isinstance(value, str):
             try:
                 expression = database.json_key_exists(raw_column, value)
             except NotImplementedError:
diff -r 550efceff67d -r 7a8606077f4c 
trytond/trytond/tests/test_field_multiselection.py
--- a/trytond/trytond/tests/test_field_multiselection.py        Wed Jan 28 
15:58:01 2026 +0100
+++ b/trytond/trytond/tests/test_field_multiselection.py        Mon Jan 19 
16:40:01 2026 +0100
@@ -209,6 +209,30 @@
         self.assertEqual(selections, [selection])
 
     @with_transaction()
+    def test_search_in_none(self):
+        "Test search selection in None"
+        selection, = self.Selection.create([{
+                    'selects': ['foo', 'bar'],
+                    }])
+
+        result = self.Selection.search([
+                ('selects', 'in', None),
+                ])
+        self.assertEqual(result, [])
+
+    @with_transaction()
+    def test_search_not_in_none(self):
+        "Test search selection not in None"
+        selection, = self.Selection.create([{
+                    'selects': ['foo', 'bar'],
+                    }])
+
+        result = self.Selection.search([
+                ('selects', 'not in', None),
+                ])
+        self.assertEqual(result, [selection])
+
+    @with_transaction()
     def test_search_in_string(self):
         "Test search selection in string"
         selection, = self.Selection.create([{

Reply via email to