From 0764bc41aa0d28e2a6dcbf6d169d3f8ea092a627 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Thu, 4 May 2017 16:56:57 +0200 Subject: [FIX] web: list rendering was not properly updated after discard Before this commit, when hitting the "Discard" button in an editable list view, the line switched to readonly mode but with the undiscarded data (even though the data was properly discarded and not saved). Fortunately, the fix is in fact making the save/discard/update system more consistent. Here are some reasons why: - the `_confirmSave` method is now used after a save or a discard (while it was before only called on readonly views where a change was made by a special field widget). - Abandonning a record (discarding a new unsaved one), is now the responsability of `discardChanges` (and not `_setMode`). - The renderer `updateState` method is used when its state is updated. - ... Note that setting the renderer mode is now taking care of deferreds properly (the widgets deferred are now considered when switching a row to readonly/edit mode). --- addons/web/static/src/js/fields/relational_fields.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'addons/web/static/src/js/fields/relational_fields.js') diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js index 135d21e5adf..51986224c78 100644 --- a/addons/web/static/src/js/fields/relational_fields.js +++ b/addons/web/static/src/js/fields/relational_fields.js @@ -638,7 +638,7 @@ var FieldX2Many = AbstractField.extend({ return this._super(); } if (this.renderer) { - this.renderer.updateState(this.value); + this.renderer.updateState(this.value, {}); this.pager.updateState({ size: this.value.count }); return $.when(); } @@ -746,8 +746,8 @@ var FieldX2Many = AbstractField.extend({ onFailure: def.reject.bind(def), }); } else { - self.renderer.setRowMode(recordID, 'readonly'); - def.resolve(); + self.renderer.setRowMode(recordID, 'readonly') + .done(def.resolve.bind(def)); } }); return def; @@ -791,7 +791,8 @@ var FieldX2Many = AbstractField.extend({ */ _onEditLine: function (ev) { ev.stopPropagation(); - this.renderer.setRowMode(ev.data.recordID, 'edit'); + this.renderer.setRowMode(ev.data.recordID, 'edit') + .done(ev.data.onSuccess); }, /** * Updates the given record with the changes. -- cgit v1.2.3