[FIX] web: context when read on multi edit
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) <ged@openerp.com>
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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: '<tree editable="top">' +
|
||||
'<field name="foo"/>' +
|
||||
'</tree>',
|
||||
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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user