[FIX] web: no selected records after multi edition

Backport of 4b7ba864d0

After editing multiple record, we want don't want any
record selected. This commit ensures that.
This commit is contained in:
Julien Mougenot
2019-09-18 06:11:03 +00:00
committed by Aaron Bohy
parent e00121d500
commit c3ac181665
3 changed files with 14 additions and 7 deletions
@@ -402,7 +402,7 @@ var ListController = BasicController.extend({
self._updateButtons('readonly');
var state = self.model.get(self.handle);
self.renderer.updateState(state, {});
resolve();
resolve(Object.keys(changes));
})
.guardedCatch(rejectAndDiscard);
},
@@ -439,17 +439,20 @@ ListRenderer.include({
var recordWidgets = this.allFieldWidgets[recordID];
toggleWidgets(true);
var prom = new Promise(function (resolve, reject) {
return new Promise(function (resolve, reject) {
self.trigger_up('save_line', {
recordID: recordID,
onSuccess: resolve,
onFailure: reject,
});
});
prom.guardedCatch(function() {
}).then(function (changedFields) {
// If any field has changed and if the list is in multiple edition,
// we send a truthy boolean to _selectRow to tell it not to select
// the following record.
return changedFields && changedFields.length && self.inMultipleRecordEdition(recordID);
}).guardedCatch(function () {
toggleWidgets(false);
});
return prom;
function toggleWidgets(disabled) {
_.each(recordWidgets, function (widget) {
@@ -1058,7 +1061,10 @@ ListRenderer.include({
var recordId = this._getRecordID(rowIndex);
// To select a row, the currently selected one must be unselected first
var self = this;
return this.unselectRow().then(function () {
return this.unselectRow().then(function (noSelectNext) {
if (noSelectNext) {
return Promise.resolve();
}
if (!recordId) {
// The row to selected doesn't exist anymore (probably because
// an onchange triggered when unselecting the previous one
+2 -1
View File
@@ -4446,7 +4446,7 @@ QUnit.module('Views', {
});
QUnit.test('editable list view: multi edition', async function (assert) {
assert.expect(21);
assert.expect(22);
var list = await createView({
View: ListView,
@@ -4509,6 +4509,7 @@ QUnit.module('Views', {
await testUtils.dom.click(list.$('.o_data_row:eq(1) .o_data_cell:eq(0)'));
assert.ok($('.modal').text().includes('2 selected records'), "the number of records should be correctly displayed");
await testUtils.dom.click($('.modal .btn-primary'));
assert.containsNone(list, '.o_data_cell input.o_field_widget', "no field should be editable anymore");
assert.verifySteps(['write', 'read']);
assert.strictEqual(list.$('.o_data_row:eq(0) .o_data_cell').text(), "yop666",
"the first row should be updated");