summaryrefslogtreecommitdiff
path: root/odoo/addons/test_new_api/tests/test_new_fields.py
diff options
context:
space:
mode:
authorRaphael Collet <rco@odoo.com>2021-05-28 18:29:07 +0000
committerRaphael Collet <rco@odoo.com>2021-05-31 09:48:22 +0000
commit21003506c061e59ec89d0e0450fbcd1d3e2da825 (patch)
tree7c53d2fb8dc80288dea0d171a7a1073206c79c36 /odoo/addons/test_new_api/tests/test_new_fields.py
parenta11662e525aad9a843acf54b717f3df18d8c2cab (diff)
[FIX] core: origin of main record in onchangeHEAD14.0
When invoking onchange() on a line in a one2many field, the inverse many2one field is given as a dict of values. Those values are the ones of the "container" record in the form view, and they include the "id" of the container record. The method onchange() instantiates the container record as a new record with the given values. Fix the code to set the expected "origin" of that record to the record with the given "id". closes odoo/odoo#71474 X-original-commit: ebfb5d90fd4ff65ee1d2fc73faf8f9eaa18f4521 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.py16
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 b3a83605d19..b10f10d3609 100644
--- a/odoo/addons/test_new_api/tests/test_new_fields.py
+++ b/odoo/addons/test_new_api/tests/test_new_fields.py
@@ -1678,6 +1678,22 @@ class TestFields(TransactionCaseWithUserDemo):
self.assertNotEqual(new_disc.participants, disc.participants)
self.assertEqual(new_disc.participants._origin, disc.participants)
+ # provide many2one field as a dict of values; the value is a new record
+ # with the given 'id' as origin (if given, of course)
+ new_msg = disc.messages.new({
+ 'discussion': {'name': disc.name},
+ })
+ self.assertTrue(new_msg.discussion)
+ self.assertFalse(new_msg.discussion.id)
+ self.assertFalse(new_msg.discussion._origin)
+
+ new_msg = disc.messages.new({
+ 'discussion': {'name': disc.name, 'id': disc.id},
+ })
+ self.assertTrue(new_msg.discussion)
+ self.assertFalse(new_msg.discussion.id)
+ self.assertEqual(new_msg.discussion._origin, disc)
+
# check convert_to_write
tag = self.env['test_new_api.multi.tag'].create({'name': 'Foo'})
rec = self.env['test_new_api.multi'].create({