diff options
| author | Sébastien Theys <seb@odoo.com> | 2020-01-22 17:06:38 +0000 |
|---|---|---|
| committer | Sébastien Theys <seb@odoo.com> | 2020-01-24 17:13:05 +0000 |
| commit | 25708586a709649e8b505e89723671dd58d9800e (patch) | |
| tree | d67f9c3fbccb7e836bd271df99fdcc34504d56a4 /odoo/addons/test_new_api/tests/test_new_fields.py | |
| parent | e7aeb6eb072c77723b99bd26ab29ede4deee12f8 (diff) | |
[FIX] fields, test_new_api: fix m2m commands in batch
Before this commit executing m2m commands in batch would lead to undesired
results, such as duplicating the related records on every subsequent record of
the batch.
Indeed since [1] the `create` and `unlink` are called in a loop, but their
content was not reset at each iteration.
[1] 9920f20e4c7753bc17bea71dea3a90f7de687196
closes odoo/odoo#43950
X-original-commit: 0800f64b011c8f020c0d7dd6e1c149aebd1a4627
Signed-off-by: Sébastien Theys (seb) <seb@odoo.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 | 8 |
1 files changed, 8 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 e79e3c306fa..e5ad38974bc 100644 --- a/odoo/addons/test_new_api/tests/test_new_fields.py +++ b/odoo/addons/test_new_api/tests/test_new_fields.py @@ -1936,6 +1936,14 @@ class TestX2many(common.TransactionCase): result = recs.search([('id', 'in', recs.ids), ('lines', '!=', False)]) self.assertEqual(result, recs - recZ) + def test_create_batch_m2m(self): + lines = self.env['test_new_api.multi.line'].create([{ + 'tags': [(0, 0, {'name': str(j)}) for j in range(3)], + } for i in range(3)]) + self.assertEqual(len(lines), 3) + for line in lines: + self.assertEqual(len(line.tags), 3) + class TestHtmlField(common.TransactionCase): |
