Make search on boolean non equals to True is the same as different of False

Closes #14815
(grafted from 7ac4b470f9e36f846b28d4c12e5e121e204d4aa1)

--HG--
branch : 7.0
This commit is contained in:
Cédric Krier committed 2026-05-06 09:23:35 +02:00
1 parent ce96f6289d
commit e5066b2fce
2 files changed
+30

No files matched your search

+4
View File
@@ -1,6 +1,8 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from sql import Null
from .field import Field
@@ -35,4 +37,6 @@ class Boolean(Field):
expression |= (column == conv[value])
else:
expression &= (column != conv[value])
elif value and operator == '!=':
expression |= (column == Null)
return expression
@@ -228,6 +228,32 @@ class FieldBooleanTestCase(unittest.TestCase):
])
self.assertListEqual(booleans, [])
@with_transaction()
def test_search_equals_true_with_none(self):
"Test search boolean equals True with None"
Boolean = Pool().get('test.boolean')
boolean, = Boolean.create([{
'boolean': None,
}])
booleans = Boolean.search([
('boolean', '=', True),
])
self.assertListEqual(booleans, [])
@with_transaction()
def test_search_non_equals_true_with_none(self):
"Test search boolean non equals True with None"
Boolean = Pool().get('test.boolean')
boolean, = Boolean.create([{
'boolean': None,
}])
booleans = Boolean.search([
('boolean', '!=', True),
])
self.assertListEqual(booleans, [boolean])
@with_transaction()
def test_write_false(self):
"Test write boolean False"