diff options
| author | Aaron Bohy <aab@odoo.com> | 2017-05-15 15:04:01 +0200 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-05-16 08:49:26 +0200 |
| commit | ac092e9ccdc71ea6c95ca7c0833337e7a911fcad (patch) | |
| tree | fed11a4354c65445272eebf36b77a03be437c200 /addons/web/static/src | |
| parent | 55de60db6e2fb7851526c258f1801f7d321974b7 (diff) | |
[FIX] web: List: force grouped lists to be non editable
Editable grouped list views isn't a supported feature. Before this
rev., grouped lists weren't automatically set as non editable, so
it could cause crashes when the user clicked on rows of grouped
lists with editable="top" or "bottom".
This was for example the case in Timesheets > All timesheets ->
go to list view.
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/js/views/list/list_editable_renderer.js | 18 |
1 files changed, 13 insertions, 5 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 49badb22f85..a857fee7103 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 @@ -44,8 +44,6 @@ ListRenderer.include({ // of each line, so the user can delete a record. this.addTrashIcon = params.addTrashIcon; - this.editable = this.arch.attrs.editable; - this.currentRow = null; this.currentCol = null; }, @@ -224,6 +222,16 @@ ListRenderer.include({ return n; }, /** + * Returns true iff the list is editable, i.e. if it isn't grouped and if + * the editable attribute is set on the root node of its arch. + * + * @private + * @returns {boolean} + */ + _isEditable: function () { + return this.mode === 'edit' && !this.state.groupedBy.length && this.arch.attrs.editable; + }, + /** * Move the cursor on the end of the previous line, if possible. * If there is no previous line, then we create a new record. * @@ -474,7 +482,7 @@ ListRenderer.include({ _onCellClick: function (event) { // The special_click property explicitely allow events to bubble all // the way up to bootstrap's level rather than being stopped earlier. - if (this.mode === 'readonly' || !this.editable || $(event.target).prop('special_click')) { + if (!this._isEditable() || $(event.target).prop('special_click')) { return; } var $td = $(event.currentTarget); @@ -486,7 +494,7 @@ ListRenderer.include({ /** * We need to manually unselect row, because noone else would do it */ - _onEmptyRowClick: function (event) { + _onEmptyRowClick: function () { this._unselectRow(); }, /** @@ -570,7 +578,7 @@ ListRenderer.include({ * @private */ _onRowClicked: function () { - if (this.mode === 'readonly' || !this.editable) { + if (!this._isEditable()) { this._super.apply(this, arguments); } }, |
