summaryrefslogtreecommitdiff
path: root/odoo/addons/test_new_api/tests/test_new_fields.py
diff options
context:
space:
mode:
authorRaphael Collet <rco@odoo.com>2020-01-08 10:53:51 +0000
committerRaphael Collet <rco@odoo.com>2020-01-16 15:11:57 +0000
commita8ea77a771730942909a9d22ed9151cd857be0d6 (patch)
tree3177b82a4f14f786b27cec7a5f4c17c9cadb12d1 /odoo/addons/test_new_api/tests/test_new_fields.py
parent170eaa4743562bdb54a569b492aea632472bd525 (diff)
[FIX] base: browse(record) in company-dependent field value
The faulty code modifies a dictionary in-place to apply a formatting function to each value. In this case, the formatting is `browse`, and the issue occurs when `ids` contain duplicates: for id in ids: result[id] = format(result.get(id, default)) Fix it by returning a new dictionary based on `result`. X-original-commit: bd4565e227c7196604af9c5c51ce136a2beac088
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.py6
1 files changed, 6 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 d476f6b843d..e79e3c306fa 100644
--- a/odoo/addons/test_new_api/tests/test_new_fields.py
+++ b/odoo/addons/test_new_api/tests/test_new_fields.py
@@ -998,6 +998,12 @@ class TestFields(TransactionCaseWithUserDemo):
self.assertEqual(record.with_user(user1).tag_id, tag2)
self.assertEqual(record.with_user(user2).tag_id, tag0)
+ # regression: duplicated records caused values to be browse(browse(id))
+ recs = record.create({}) + record + record
+ recs.invalidate_cache()
+ for rec in recs.with_user(user0):
+ self.assertIsInstance(rec.tag_id.id, int)
+
# unlink value of a many2one (tag2), and check again
tag2.unlink()
self.assertEqual(record.with_user(user0).tag_id, tag1)