summaryrefslogtreecommitdiff
path: root/odoo/addons/test_new_api
diff options
context:
space:
mode:
authorRaphael Collet <rco@odoo.com>2020-06-19 12:00:09 +0000
committerRaphael Collet <rco@odoo.com>2020-06-23 14:00:42 +0000
commitea83473eab2ba3f23673dd2561f3c80550a4671d (patch)
tree0fbca11adeb3cb3d363fc20bb595ac137ed53e22 /odoo/addons/test_new_api
parent536759644e13448f1c2b14d95cc8ecb44e5f0b24 (diff)
[FIX] core: flush() with one2many fields
This ensures that flushing a one2many field automatically flushes its inverse many2one/integer field. Without that, a search like: model.search([('o2m_ids', 'in', ids)]) can return incorrect results. closes odoo/odoo#53514 X-original-commit: b91b485a5d9a62acfe44b12c64a46dcca23981ce Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Diffstat (limited to 'odoo/addons/test_new_api')
-rw-r--r--odoo/addons/test_new_api/tests/test_new_fields.py15
1 files changed, 15 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 fa2f8007bb4..ef3ce6b1c0a 100644
--- a/odoo/addons/test_new_api/tests/test_new_fields.py
+++ b/odoo/addons/test_new_api/tests/test_new_fields.py
@@ -1625,6 +1625,21 @@ class TestFields(TransactionCaseWithUserDemo):
line.move_id = move2
self.assertEqual(line.move_id, move2)
+ def test_72_relational_inverse(self):
+ """ Check the consistency of relational fields with inverse(s). """
+ move1 = self.env['test_new_api.move'].create({})
+ move2 = self.env['test_new_api.move'].create({})
+
+ # makes sure that line.move_id is flushed before search
+ line = self.env['test_new_api.move_line'].create({'move_id': move1.id})
+ moves = self.env['test_new_api.move'].search([('line_ids', 'in', line.id)])
+ self.assertEqual(moves, move1)
+
+ # makes sure that line.move_id is flushed before search
+ line.move_id = move2
+ moves = self.env['test_new_api.move'].search([('line_ids', 'in', line.id)])
+ self.assertEqual(moves, move2)
+
def test_80_copy(self):
Translations = self.env['ir.translation']
discussion = self.env.ref('test_new_api.discussion_0')