diff options
| author | Aaron Bohy <aab@odoo.com> | 2017-08-30 08:55:03 +0200 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-08-30 11:23:28 +0200 |
| commit | 551dc26940f2f33af7fa71c7d1256fe4f2f2fd8f (patch) | |
| tree | dda21184a4d390232d8d923beedae9240b398020 /addons/web/static/src | |
| parent | 4f61e7f0481fa2e2bfd806d92ea77f07b78d42de (diff) | |
[FIX] web: tab navigation in editable list with create="0"
Before this rev., when the user pressed 'TAB' in the last cell of
the last row of an editable list with attribute create="0", a new
line was added to the list, thus totally ignoring the attribute.
Now, it goes back to the first cell of the first row instead, as it
was before the new views.
Closes #19053
Diffstat (limited to 'addons/web/static/src')
3 files changed, 16 insertions, 3 deletions
diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js index e05a53194c3..67218e5decd 100644 --- a/addons/web/static/src/js/fields/relational_fields.js +++ b/addons/web/static/src/js/fields/relational_fields.js @@ -1063,7 +1063,11 @@ var FieldOne2Many = FieldX2Many.extend({ ev.stopPropagation(); if (this.editable) { - if (!this.creatingRecord) { + if (!this.activeActions.create) { + if (ev.data.onFail) { + ev.data.onFail(); + } + } else if (!this.creatingRecord) { this.creatingRecord = true; this._setValue({ operation: 'CREATE', diff --git a/addons/web/static/src/js/views/list/list_controller.js b/addons/web/static/src/js/views/list/list_controller.js index 3b74f140e4d..33637e53f52 100644 --- a/addons/web/static/src/js/views/list/list_controller.js +++ b/addons/web/static/src/js/views/list/list_controller.js @@ -313,7 +313,11 @@ var ListController = BasicController.extend({ */ _onAddRecord: function (event) { event.stopPropagation(); - this._addRecord(); + if (this.activeActions.create) { + this._addRecord(); + } else if (event.data.onFail) { + event.data.onFail(); + } }, /** * Handles a click on a button by performing its action. 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 3cd93bb6e8b..c5f65ecc6e2 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 @@ -341,7 +341,12 @@ ListRenderer.include({ if (this.currentRow < this.state.data.length - 1) { this._selectCell(this.currentRow + 1, 0); } else { - this.unselectRow().then(this.trigger_up.bind(this, 'add_record')); + var self = this; + this.unselectRow().then(function () { + self.trigger_up('add_record', { + onFail: self._selectCell.bind(self, 0, 0, {}), + }); + }); } }, /** |
