Use the target id to compute the filter clause of a O2M field compared to None
Closes #14373 (grafted from 6b5e31b69ae62dabb2ad3253d9018945a467dbf1) --HG-- branch : 7.0
This commit is contained in:
@@ -350,7 +350,7 @@ class One2Many(Field):
|
||||
if self.filter:
|
||||
query = Target.search(
|
||||
self.filter, order=[], query=True)
|
||||
where &= origin.in_(query)
|
||||
where &= target.id.in_(query)
|
||||
query = target.select(origin, where=where)
|
||||
expression = ~table.id.in_(query)
|
||||
else:
|
||||
|
||||
@@ -610,6 +610,21 @@ class FieldOne2ManyTestCase(
|
||||
self.assertEqual(len(filtered.targets), 4)
|
||||
self.assertEqual(filtered_target.value, 3)
|
||||
|
||||
@with_transaction()
|
||||
def test_search_equals_filter(self):
|
||||
"Test search one2many equals with filter"
|
||||
One2Many = Pool().get('test.one2many_filter')
|
||||
one2many, = One2Many.create([{
|
||||
'targets': [('create', [{'value': 3}])],
|
||||
}])
|
||||
|
||||
one2manys = One2Many.search([('targets', '=', None)])
|
||||
one2manys_filtered = One2Many.search(
|
||||
[('filtered_targets', '=', None)])
|
||||
|
||||
self.assertListEqual(one2manys, [])
|
||||
self.assertListEqual(one2manys_filtered, [])
|
||||
|
||||
@with_transaction()
|
||||
def test_search_non_equals_filter(self):
|
||||
"Test search one2many non equals with filter"
|
||||
|
||||
Reference in New Issue
Block a user