[FIX] web: no selected records after multi edition
After editing multiple record, we want don't want any record selected. This commit ensures that. closes odoo/odoo#35678 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
@@ -406,7 +406,7 @@ var ListController = BasicController.extend({
|
||||
this._updateButtons('readonly');
|
||||
const state = this.model.get(this.handle);
|
||||
this.renderer.updateState(state, {});
|
||||
resolve();
|
||||
resolve(Object.keys(changes));
|
||||
})
|
||||
.guardedCatch(rejectAndDiscard);
|
||||
},
|
||||
|
||||
@@ -430,7 +430,6 @@ ListRenderer.include({
|
||||
* user refuses to discard its changes.
|
||||
*/
|
||||
unselectRow: function () {
|
||||
var self = this;
|
||||
// Protect against calling this method when no row is selected
|
||||
if (this.currentRow === null) {
|
||||
return Promise.resolve();
|
||||
@@ -439,17 +438,20 @@ ListRenderer.include({
|
||||
var recordWidgets = this.allFieldWidgets[recordID];
|
||||
toggleWidgets(true);
|
||||
|
||||
var prom = new Promise(function (resolve, reject) {
|
||||
self.trigger_up('save_line', {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.trigger_up('save_line', {
|
||||
recordID: recordID,
|
||||
onSuccess: resolve,
|
||||
onFailure: reject,
|
||||
});
|
||||
});
|
||||
prom.guardedCatch(function() {
|
||||
}).then(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 && this.inMultipleRecordEdition(recordID);
|
||||
}).guardedCatch(() => {
|
||||
toggleWidgets(false);
|
||||
});
|
||||
return prom;
|
||||
|
||||
function toggleWidgets(disabled) {
|
||||
_.each(recordWidgets, function (widget) {
|
||||
@@ -1004,7 +1006,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(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
|
||||
|
||||
@@ -4448,7 +4448,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,
|
||||
@@ -4511,6 +4511,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");
|
||||
|
||||
Reference in New Issue
Block a user