[FIX] web: list: multi edition only between selected records

Before this commit, if a record was selected and another one was edited,
it was considered as multi edition.

Now, the multi edition only works if the edited record is included in the
selection; else it will be the only edited record (single edition).

Task 2068280
This commit is contained in:
Julien Mougenot
2019-09-18 11:31:43 +00:00
committed by Aaron Bohy
parent 6ecf325769
commit 4a3315fa22
2 changed files with 27 additions and 5 deletions
@@ -339,9 +339,7 @@ ListRenderer.include({
* @returns {boolean}
*/
inMultipleRecordEdition: function (recordId) {
const record = this._getRecord(recordId) || {};
const recordIds = [...new Set([recordId, ...this.selection])];
return this.editable && recordIds.length > 1 && record.res_id;
return this.editable && this.selection.length > 1 && this.selection.includes(recordId);
},
/**
* Removes the line associated to the given recordID (the index of the row
+26 -2
View File
@@ -5273,6 +5273,32 @@ QUnit.module('Views', {
list.destroy();
});
QUnit.test('editable list view: single edition with selected records', async function (assert) {
assert.expect(2);
const list = await createView({
arch: `<tree editable="top"><field name="foo"/></tree>`,
data: this.data,
model: 'foo',
View: ListView,
});
// Select first record
await testUtils.dom.click(list.$('.o_data_row:eq(0) .o_list_record_selector input'));
// Edit the second
await testUtils.dom.click(list.$('.o_data_row:eq(1) .o_data_cell:first()'));
await testUtils.fields.editInput(list.$('.o_data_row:eq(1) .o_data_cell:first() input'), "oui");
await testUtils.dom.click($('.o_list_button_save'));
assert.strictEqual(list.$('.o_data_row:eq(0) .o_data_cell:first()').text(), "yop",
"First row should remain unchanged");
assert.strictEqual(list.$('.o_data_row:eq(1) .o_data_cell:first()').text(), "oui",
"Second row should have been updated");
list.destroy();
});
QUnit.test('editable list view: multi edition', async function (assert) {
assert.expect(22);
@@ -5323,8 +5349,6 @@ QUnit.module('Views', {
assert.verifySteps(['create', 'read']);
// edit a field
// We deliberately unselect the first row to check the multi edit union (recordId + selectedRecordIds)
await testUtils.dom.click(list.$('.o_data_row:eq(0) .o_list_record_selector input'));
await testUtils.dom.click(list.$('.o_data_row:eq(0) .o_data_cell:eq(1)'));
await testUtils.fields.editInput(list.$('.o_field_widget[name=int_field]'), 666);
await testUtils.dom.click(list.$('.o_data_row:eq(0) .o_data_cell:eq(0)'));