details: https://code.tryton.org/tryton/commit/f69b5fa904c2
branch: 8.0
user: Cédric Krier <[email protected]>
date: Wed May 06 09:23:35 2026 +0200
description:
Make search on boolean non equals to True is the same as different of
False
Closes #14815
(grafted from 7ac4b470f9e36f846b28d4c12e5e121e204d4aa1)
diffstat:
trytond/trytond/model/fields/boolean.py | 4 ++++
trytond/trytond/tests/test_field_boolean.py | 26 ++++++++++++++++++++++++++
2 files changed, 30 insertions(+), 0 deletions(-)
diffs (55 lines):
diff -r 71de9a39a115 -r f69b5fa904c2 trytond/trytond/model/fields/boolean.py
--- a/trytond/trytond/model/fields/boolean.py Tue May 05 00:11:08 2026 +0200
+++ b/trytond/trytond/model/fields/boolean.py Wed May 06 09:23:35 2026 +0200
@@ -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
@@ -33,4 +35,6 @@
expression |= (column == conv[value])
else:
expression &= (column != conv[value])
+ elif value and operator == '!=':
+ expression |= (column == Null)
return expression
diff -r 71de9a39a115 -r f69b5fa904c2 trytond/trytond/tests/test_field_boolean.py
--- a/trytond/trytond/tests/test_field_boolean.py Tue May 05 00:11:08
2026 +0200
+++ b/trytond/trytond/tests/test_field_boolean.py Wed May 06 09:23:35
2026 +0200
@@ -230,6 +230,32 @@
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"
Boolean = Pool().get('test.boolean')