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);