From 4d0f36ac01b7a68d3ed0669f6e26f6a508bcbf36 Mon Sep 17 00:00:00 2001 From: svs-odoo Date: Tue, 23 Jul 2019 12:54:12 +0000 Subject: [PATCH] [FIX] web: context when read on multi edit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this commit, in list editable, when user save multiple records in the same time, the context is passed for the write but not for the read. Now, the context is passed also for the read. closes odoo/odoo#35113 Signed-off-by: Géry Debongnie (ged) --- .../static/src/js/views/list/list_model.js | 4 +- addons/web/static/tests/views/list_tests.js | 37 +++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/js/views/list/list_model.js b/addons/web/static/src/js/views/list/list_model.js index 6c592bd977e..25fdf28954c 100644 --- a/addons/web/static/src/js/views/list/list_model.js +++ b/addons/web/static/src/js/views/list/list_model.js @@ -52,17 +52,19 @@ odoo.define('web.ListModel', function (require) { var model = records[0].model; var recordResIds = _.pluck(records, 'res_id'); var fieldNames = records[0].getFieldNames(); + var context = records[0].getContext(); return this._rpc({ model: model, method: 'write', args: [recordResIds, changes], - context: records[0].getContext(), + context: context, }).then(function () { return self._rpc({ model: model, method: 'read', args: [recordResIds, fieldNames], + context: context, }); }).then(function (results) { results.forEach(function (data) { diff --git a/addons/web/static/tests/views/list_tests.js b/addons/web/static/tests/views/list_tests.js index aed485aad66..e2359401fde 100644 --- a/addons/web/static/tests/views/list_tests.js +++ b/addons/web/static/tests/views/list_tests.js @@ -4244,6 +4244,43 @@ QUnit.module('Views', { list.destroy(); }); + QUnit.test('editable list view: contexts with multiple edit', async function (assert) { + assert.expect(4); + + var list = await createView({ + View: ListView, + model: 'foo', + data: this.data, + arch: '' + + '' + + '', + mockRPC: function (route, args) { + if (route === '/web/dataset/call_kw/foo/write' || + route === '/web/dataset/call_kw/foo/read') { + var context = args.kwargs.context; + assert.strictEqual(context.active_field, 2, "context should be correct"); + assert.strictEqual(context.someKey, 'some value', "context should be correct"); + } + return this._super.apply(this, arguments); + }, + session: { + user_context: {someKey: 'some value'}, + }, + viewOptions: { + context: {active_field: 2}, + }, + }); + + // Uses the main selector to select all lines. + await testUtils.dom.click(list.$('.o_content input:first')); + await testUtils.dom.click(list.$('.o_data_cell:first')); + // Edits first record then confirms changes. + await testUtils.fields.editInput(list.$('.o_field_widget[name=foo]'), 'legion'); + await testUtils.dom.click($('.modal-dialog button.btn-primary')); + + list.destroy(); + }); + QUnit.test('editable list view: multi edition', async function (assert) { assert.expect(19);