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 7be3f3d4e29..38b3066a4d3 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 @@ -366,7 +366,7 @@ ListRenderer.include({ // if we are just changing active cell in the same row, activate the // corresponding widget and return - if (rowIndex === this.currentRow && colIndex !== this.currentCol) { + if (rowIndex === this.currentRow) { var w = _.findWhere(this.widgets, { __rowIndex: rowIndex, __colIndex: colIndex diff --git a/addons/web/static/test/views/list_tests.js b/addons/web/static/test/views/list_tests.js index 269412036c8..0401f555573 100644 --- a/addons/web/static/test/views/list_tests.js +++ b/addons/web/static/test/views/list_tests.js @@ -970,6 +970,44 @@ QUnit.module('Views', { "should have formatted the datetime"); list.destroy(); }); + + QUnit.test('edit a row by clicking on a readonly field', function (assert) { + assert.expect(8); + + this.data.foo.fields.foo.readonly = true; + + var list = createView({ + View: ListView, + model: 'foo', + data: this.data, + arch: '', + }); + + assert.ok(list.$('.o_data_row:first td:nth(1)').hasClass('o_readonly'), + "foo field cells should have class 'o_readonly'"); + + // edit the first row + list.$('.o_data_row:first td:nth(1)').click(); + assert.ok(list.$('.o_data_row:first').hasClass('o_selected_row'), + "first row should be selected"); + assert.ok(list.$('.o_data_row:first td:nth(1)').hasClass('o_readonly'), + "foo field cells should have class 'o_readonly'"); + assert.strictEqual(list.$('.o_data_row:first td:nth(1)').text(), 'yop', + "no widget should be rendered for readonly fields"); + assert.ok(list.$('.o_data_row:first td:nth(2)').hasClass('o_edit_mode'), + "field 'int_field' should be in edition"); + assert.strictEqual(list.$('.o_data_row:first td:nth(2) input').length, 1, + "a widget for field 'int_field should have been rendered'"); + + // click again on readonly cell of first line: nothing should have changed + list.$('.o_data_row:first td:nth(1)').click(); + assert.ok(list.$('.o_data_row:first').hasClass('o_selected_row'), + "first row should be selected"); + assert.strictEqual(list.$('.o_data_row:first td:nth(2) input').length, 1, + "a widget for field 'int_field' should have been rendered (only once)"); + + list.destroy(); + }); }); });