diff options
| author | Sébastien Theys <seb@odoo.com> | 2018-08-21 16:13:23 +0200 |
|---|---|---|
| committer | Sébastien Theys <seb@odoo.com> | 2018-08-22 11:51:30 +0200 |
| commit | 241704536d38f387d076c73c503b36b062a91ff7 (patch) | |
| tree | 4e415511662d4f6a7ed7c4a6b688c387eeac25e8 /addons/web/static/src/js | |
| parent | 46bfe9ad6596394a06d98796841f3107bddf3aeb (diff) | |
[FIX] web: allow o2m navigation to work from required inputs
In a one2many, pressing ENTER or TAB from a required input (of type text or char) that is on the last editable column of its line would fail to navigate to next line.
The issue was that the validation of the required field would happen before the change to its value was actually applied.
This commit fixes it.
PR: #26430
Task: 1869469
Diffstat (limited to 'addons/web/static/src/js')
| -rw-r--r-- | addons/web/static/src/js/fields/basic_fields.js | 4 | ||||
| -rw-r--r-- | addons/web/static/src/js/fields/relational_fields.js | 8 | ||||
| -rw-r--r-- | addons/web/static/src/js/views/list/list_editable_renderer.js | 28 |
3 files changed, 25 insertions, 15 deletions
diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index 71b2a14c434..fdefb2cf967 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -114,7 +114,7 @@ var DebouncedField = AbstractField.extend({ */ commitChanges: function () { if (this._isDirty && this.mode === 'edit') { - this._doAction(); + return this._doAction(); } }, @@ -135,7 +135,7 @@ var DebouncedField = AbstractField.extend({ // do anything (commitChanges ensures that if it has local changes, they // are triggered up before the widget is destroyed, if necessary). if (!this.isDestroyed()) { - this._setValue(this._getValue()); + return this._setValue(this._getValue()); } }, /** diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js index f3125c72f29..7683cd6db94 100644 --- a/addons/web/static/src/js/fields/relational_fields.js +++ b/addons/web/static/src/js/fields/relational_fields.js @@ -1124,6 +1124,14 @@ var FieldX2Many = AbstractField.extend({ operation: 'UPDATE', id: ev.data.dataPointID, data: changes, + }).done(function () { + if (ev.data.onSuccess) { + ev.data.onSuccess(); + } + }).fail(function () { + if (ev.data.onFailure) { + ev.data.onFailure(); + } }); } }, 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 5c33a32b6d5..37bd7b153c7 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 @@ -487,22 +487,24 @@ ListRenderer.include({ * @private */ _moveToNextLine: function () { + var self = this; var record = this.state.data[this.currentRow]; - var fieldNames = this.canBeSaved(record.id); - if (fieldNames.length) { - return; - } + this.commitChanges(record.id).then(function () { + var fieldNames = self.canBeSaved(record.id); + if (fieldNames.length) { + return; + } - if (this.currentRow < this.state.data.length - 1) { - this._selectCell(this.currentRow + 1, 0); - } else { - var self = this; - this.unselectRow().then(function () { - self.trigger_up('add_record', { - onFail: self._selectCell.bind(self, 0, 0, {}), + if (self.currentRow < self.state.data.length - 1) { + self._selectCell(self.currentRow + 1, 0); + } else { + self.unselectRow().then(function () { + self.trigger_up('add_record', { + onFail: self._selectCell.bind(self, 0, 0, {}), + }); }); - }); - } + } + }); }, /** * @override |
