From 3125d20da30b972aa845d7f0884876b4ae2e6f1c Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Wed, 2 Jan 2019 15:17:12 +0000 Subject: [FIX] web: X2Many read propagates field context Most operations on X2Many widget possibly propagates a field context (name_create, name_search, ...) but the original read or read on an onchange does not. With this changeset, the field context is also used in these instances. The assertions added in the added test failed with: expected: ["world"], result: [undefined] expected: ["world","world"], result: [undefined,undefined] fixes #29203 opw-1914466 closes #29866 --- .../static/tests/fields/relational_fields_tests.js | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'addons/web/static/tests/fields') diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js index 0a5825850d6..3991d499f3d 100644 --- a/addons/web/static/tests/fields/relational_fields_tests.js +++ b/addons/web/static/tests/fields/relational_fields_tests.js @@ -10943,6 +10943,39 @@ QUnit.module('relational_fields', { form.destroy(); }); + QUnit.test('many2many read, field context is properly sent', function (assert) { + assert.expect(4); + + this.data.partner.fields.timmy.context = {hello: 'world'}; + this.data.partner.records[0].timmy = [12]; + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '
' + + '' + + '', + res_id: 1, + mockRPC: function (route, args) { + if (args.method === 'read' && args.model === 'partner_type') { + assert.step(args.kwargs.context.hello); + } + return this._super.apply(this, arguments); + }, + }); + + assert.verifySteps(['world']); + + form.$buttons.find('.o_form_button_edit').click(); + var $m2mInput = form.$('.o_field_many2manytags input'); + $m2mInput.click(); + $m2mInput.autocomplete('widget').find('li:first()').click(); + assert.verifySteps(['world', 'world']); + + form.destroy(); + }); + QUnit.module('FieldStatus'); QUnit.test('static statusbar widget on many2one field', function (assert) { -- cgit v1.2.3