Make search on boolean non equals to True is the same as different of False
Closes #14815 (grafted from 7ac4b470f9e36f846b28d4c12e5e121e204d4aa1) --HG-- branch : 8.0
This commit is contained in:
@@ -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 @@ class Boolean(Field):
|
||||
expression |= (column == conv[value])
|
||||
else:
|
||||
expression &= (column != conv[value])
|
||||
elif value and operator == '!=':
|
||||
expression |= (column == Null)
|
||||
return expression
|
||||
|
||||
@@ -229,6 +229,32 @@ class FieldBooleanTestCase(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"
|
||||
|
||||
Reference in New Issue
Block a user