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 60e27998f18..93bc48ca04b 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 @@ -1218,11 +1218,11 @@ ListRenderer.include({ return Promise.resolve(); } var wrap = options.wrap === undefined ? true : options.wrap; + var recordID = this._getRecordID(rowIndex); // Select the row then activate the widget in the correct cell var self = this; return this._selectRow(rowIndex).then(function () { - var recordID = self._getRecordID(rowIndex); var record = self._getRecord(recordID); if (fieldIndex >= (self.allFieldWidgets[record.id] || []).length) { return Promise.reject(); diff --git a/addons/web/static/tests/views/list_tests.js b/addons/web/static/tests/views/list_tests.js index a78d99e5edb..9b8beb7779a 100644 --- a/addons/web/static/tests/views/list_tests.js +++ b/addons/web/static/tests/views/list_tests.js @@ -917,6 +917,43 @@ QUnit.module('Views', { form.destroy(); }); + QUnit.test('editable list view: click on last element after creation empty new line', async function (assert) { + assert.expect(1); + + this.data.bar = { + fields: { + titi: {string: "Char", type: "char", required: true}, + int_field: {string: "int_field", type: "integer", sortable: true, required: true} + }, + records: [ + {id: 1, titi: 'cui', int_field: 2}, + {id: 2, titi: 'cuicui', int_field: 4}, + ], + }; + this.data.foo.records[0].o2m = [1, 2]; + + var form = await createView({ + View: FormView, + model: 'foo', + data: this.data, + res_id: 1, + viewOptions: { mode: 'edit' }, + arch: '
'+ + ''+ + ''+ + ''+ + ''+ + ''+ + ''+ + '
', + }); + await testUtils.dom.click(form.$('.o_field_x2many_list_row_add > a')); + await testUtils.dom.click(form.$('.o_data_row:last() > td.o_list_char')); + // This test ensure that they aren't traceback when clicking on the last row. + assert.containsN(form, '.o_data_row', 2, "list should have exactly 2 rows"); + form.destroy(); + }); + QUnit.test('basic operations for editable list renderer', async function (assert) { assert.expect(2);