diff options
| author | Raphael Collet <rco@odoo.com> | 2020-01-21 09:21:03 +0000 |
|---|---|---|
| committer | Raphael Collet <rco@odoo.com> | 2020-01-21 09:31:58 +0000 |
| commit | 9ce78bff5fb084de67034bf54a814d1f30ffda46 (patch) | |
| tree | 9c67c27bc5422dcfeed36231f77706179f7b9710 /odoo/addons/test_new_api/tests/test_new_fields.py | |
| parent | 3b4cdbebf23f131e9f71a89674ab2f9e71f2784d (diff) | |
[FIX] core: search on one2many fields with context
Consider an x2many field `foo_ids` with `context={'active_test': False}`
in its definition, and a comodel with an active field. The value of the
field includes inactive records.
Now consider a search with a domain like `[('foo_ids.bar', op, value)]`.
The search should return all the records with corecords that satisfy the
domain `[('bar', op, value)]`, including inactive corecords, because the
field's context explicitly disables filtering on the active field.
closes odoo/odoo#43625
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Diffstat (limited to 'odoo/addons/test_new_api/tests/test_new_fields.py')
| -rw-r--r-- | odoo/addons/test_new_api/tests/test_new_fields.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/odoo/addons/test_new_api/tests/test_new_fields.py b/odoo/addons/test_new_api/tests/test_new_fields.py index e5ad38974bc..0f6c7fe9bb5 100644 --- a/odoo/addons/test_new_api/tests/test_new_fields.py +++ b/odoo/addons/test_new_api/tests/test_new_fields.py @@ -1824,6 +1824,22 @@ class TestX2many(common.TransactionCase): self.assertEqual(parent.with_context(active_test=False).all_children_ids, all_children) self.assertEqual(parent.with_context(active_test=False).active_children_ids, act_children) + def test_12_active_test_one2many_search(self): + Model = self.env['test_new_api.model_active_field'] + parent = Model.create({}) + all_children = Model.create([ + {'name': 'A', 'parent_id': parent.id, 'active': True}, + {'name': 'B', 'parent_id': parent.id, 'active': False}, + ]) + + # a one2many field without context does not match its inactive children + self.assertIn(parent, Model.search([('children_ids.name', '=', 'A')])) + self.assertNotIn(parent, Model.search([('children_ids.name', '=', 'B')])) + + # a one2many field with active_test=False matches its inactive children + self.assertIn(parent, Model.search([('all_children_ids.name', '=', 'A')])) + self.assertIn(parent, Model.search([('all_children_ids.name', '=', 'B')])) + def test_search_many2many(self): """ Tests search on many2many fields. """ tags = self.env['test_new_api.multi.tag'] |
