diff options
| author | Martin Trigaux <mat@odoo.com> | 2019-07-15 07:07:48 +0000 |
|---|---|---|
| committer | Martin Trigaux <mat@odoo.com> | 2019-07-15 08:12:26 +0000 |
| commit | fd15ca19183a765e1307c4d197bf0dda30b73ab7 (patch) | |
| tree | 896042073ebc752e8bcf535f21696320c69bbe13 /addons/web/static/tests/fields/relational_fields | |
| parent | 6b8a0beda65dce688ecd0ee34828097b67a13dab (diff) | |
| parent | 1f5a4649a67908ecb6acfec37673c8149de0471f (diff) | |
[MERGE] Forward port of saas-12.4 to master up to 1f5a4649a67908
closes odoo/odoo#34850
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
Diffstat (limited to 'addons/web/static/tests/fields/relational_fields')
| -rw-r--r-- | addons/web/static/tests/fields/relational_fields/field_one2many_tests.js | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/addons/web/static/tests/fields/relational_fields/field_one2many_tests.js b/addons/web/static/tests/fields/relational_fields/field_one2many_tests.js index 508ce38a961..4f5958f65cd 100644 --- a/addons/web/static/tests/fields/relational_fields/field_one2many_tests.js +++ b/addons/web/static/tests/fields/relational_fields/field_one2many_tests.js @@ -8422,6 +8422,57 @@ QUnit.module('fields', {}, function () { form.destroy(); }); + QUnit.test('many2manys inside a one2many are fetched in batch after onchange', async function (assert) { + assert.expect(7); + + this.data.partner.onchanges = { + turtles: function (obj) { + obj.turtles = [ + [5], + [1, 1, { + turtle_foo: "leonardo", + partner_ids: [[4, 2]], + }], + [1, 2, { + turtle_foo: "donatello", + partner_ids: [[4, 2], [4, 4]], + }], + ]; + }, + }; + + var form = await createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '<form>' + + '<field name="turtles">' + + '<tree editable="bottom">' + + '<field name="turtle_foo"/>' + + '<field name="partner_ids" widget="many2many_tags"/>' + + '</tree>' + + '</field>' + + '</form>', + enableBasicModelBachedRPCs: true, + mockRPC: function (route, args) { + assert.step(args.method || route); + if (args.method === 'read') { + assert.deepEqual(args.args[0], [2, 4], + 'should read the partner_ids once, batched'); + } + return this._super.apply(this, arguments); + }, + }); + + assert.containsN(form, '.o_data_row', 2); + assert.strictEqual(form.$('.o_field_widget[name="partner_ids"]').text().replace(/\s/g, ''), + "secondrecordsecondrecordaaa"); + + assert.verifySteps(['default_get', 'onchange', 'read']); + + form.destroy(); + }); + QUnit.test('two one2many fields with same relation and onchanges', async function (assert) { // this test simulates the presence of two one2many fields with onchanges, such that // changes to the first o2m are repercuted on the second one |
