Skip to content
Permalink
Browse files

[FIX] web: list: multi edit: do not create new row

...when validating last row by pressing ENTER.

In single edition, we automatically add a new row when the user
edits the last one and presses ENTER. This is something we don't
want in multi edition.

Task 2068280
  • Loading branch information...
aab-odoo committed Sep 11, 2019
1 parent 6f25f1e commit 793e20fa847c3e70b3ced21b859367e76416c190
@@ -649,11 +649,8 @@ var ListController = BasicController.extend({
this.fieldChangedPrevented = ev;
} else if (this._inMultipleRecordEdition(ev.data.dataPointID)) {
// deal with edition of multiple lines
var _onSuccess = ev.data.onSuccess;
ev.data.onSuccess = function () {
Promise.resolve(_onSuccess()).then(function () {
self._saveMultipleRecords(ev.data.dataPointID, ev.target.__node, ev.data.changes);
});
return self._saveMultipleRecords(ev.data.dataPointID, ev.target.__node, ev.data.changes);
};
}
this._super.apply(this, arguments);
@@ -4685,6 +4685,41 @@ QUnit.module('Views', {
list.destroy();
});

QUnit.test('editable list view: multi edition: edit and validate last row', async function (assert) {
assert.expect(3);

var list = await createView({
View: ListView,
model: 'foo',
data: this.data,
arch: '<tree editable="bottom">' +
'<field name="foo"/>' +
'<field name="int_field"/>' +
'</tree>',
// in this test, we want to accurately mock what really happens, that is, input
// fields only trigger their changes on 'change' event, not on 'input'
fieldDebounce: 100000,
});

assert.containsN(list, '.o_data_row', 4);

// select all records
await testUtils.dom.click(list.$('.o_list_view thead .o_list_record_selector input'));

// edit last cell of last line
await testUtils.dom.click(list.$('.o_data_row:last .o_data_cell:last'));
testUtils.fields.editInput(list.$('.o_field_widget[name=int_field]'), '666');
await testUtils.fields.triggerKeydown(list.$('tr.o_selected_row .o_data_cell:last input'), 'enter');

assert.containsOnce(document.body, '.modal');
await testUtils.dom.click($('.modal .btn-primary'));

assert.containsN(list, '.o_data_row', 4,
"should not create a new row as we were in multi edition");

list.destroy();
});

QUnit.test('list grouped by date:month', async function (assert) {
assert.expect(1);

0 comments on commit 793e20f

Please sign in to comment.
You can’t perform that action at this time.