Skip to content
Permalink
Browse files

[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.
  • Loading branch information...
jbm-odoo committed Oct 9, 2019
1 parent 4ad7a99 commit b7d0c049645c635df0978c86f285cfe7d9dc484f
@@ -1222,6 +1222,9 @@ ListRenderer.include({
// Select the row then activate the widget in the correct cell
var self = this;
return this._selectRow(rowIndex).then(function () {
if (rowIndex >= self.state.count) {
rowIndex = self.state.count - 1;
}
var recordID = self._getRecordID(rowIndex);
var record = self._getRecord(recordID);
if (fieldIndex >= (self.allFieldWidgets[record.id] || []).length) {
@@ -917,6 +917,44 @@ 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>',
debug: true
});
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.strictEqual(form.$('.o_data_row').length, 2, "list should have exactly 2 rows");
form.destroy();
});

QUnit.test('basic operations for editable list renderer', async function (assert) {
assert.expect(2);

0 comments on commit b7d0c04

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