diff options
| author | jbm-odoo <jbm@odoo.com> | 2019-10-09 15:01:39 +0000 |
|---|---|---|
| committer | fw-bot <otis@odoo.com> | 2019-10-11 09:15:09 +0000 |
| commit | 3fa123d69fb5d5c1e396bd8307eedc2a3549e72c (patch) | |
| tree | dde6056db4bec405c2eb69dfedfcf5b4bc3fa05b /addons/web/static | |
| parent | 93c657914ca0529171cd3343e059f38340a2f8a9 (diff) | |
[FIX] web: List editable top select last row
Before this commit, when we have a list (editable top) in a form
with some mandatory fields and some existing rows. If we click on
'add a line', a new empty line appear on the top, then we click on
the last row, the empty row will disappear and we will have a
traceback.
After this commit, if we repeat this scenario, we click on the last
row, we will be able to edit this last row.
closes odoo/odoo#38471
X-original-commit: 996f77b03eaf6dd646b1816e7f70209d5ee6f8df
Signed-off-by: jbm-odoo <jbm-odoo@users.noreply.github.com>
Diffstat (limited to 'addons/web/static')
| -rw-r--r-- | addons/web/static/src/js/views/list/list_editable_renderer.js | 2 | ||||
| -rw-r--r-- | addons/web/static/tests/views/list_tests.js | 37 |
2 files changed, 38 insertions, 1 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 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: '<form>'+ + '<field name="o2m">'+ + '<tree editable="top">'+ + '<field name="int_field" widget="handle"/>'+ + '<field name="titi"/>'+ + '</tree>'+ + '</field>'+ + '</form>', + }); + 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); |
