summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Mougenot <jum@odoo.com>2019-09-11 12:38:34 +0000
committerAaron Bohy <aab@odoo.com>2019-09-18 11:31:43 +0000
commit4a3315fa2245cea287bf02e1eff2516e80ed62a9 (patch)
treeb4472737bbdb9fbdb3e2a8fedc5dcf960cfd1f1a
parent6ecf325769381b495ca53f102825c5dafe9b8712 (diff)
[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
-rw-r--r--addons/web/static/src/js/views/list/list_editable_renderer.js4
-rw-r--r--addons/web/static/tests/views/list_tests.js28
2 files changed, 27 insertions, 5 deletions
diff --git a/addons/web/static/src/js/views/list/list_editable_renderer.js b/addons/web/static/src/js/views/list/list_editable_renderer.js
index d9cc1115917..1aec18f6fb7 100644
--- a/addons/web/static/src/js/views/list/list_editable_renderer.js
+++ b/addons/web/static/src/js/views/list/list_editable_renderer.js
@@ -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
diff --git a/addons/web/static/tests/views/list_tests.js b/addons/web/static/tests/views/list_tests.js
index 245a5ac21b3..16dfad681ac 100644
--- a/addons/web/static/tests/views/list_tests.js
+++ b/addons/web/static/tests/views/list_tests.js
@@ -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)'));