diff options
| author | Aaron Bohy <aab@odoo.com> | 2018-05-25 15:44:34 +0200 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2018-05-28 07:24:16 +0200 |
| commit | 5aa0e0bc2431882d36604338b23566c0e9f8c6e7 (patch) | |
| tree | bd2d897ffdbdd4043b03d9ddcacf2bf7285fdfe5 /addons/web/static/src/js/views/abstract_controller.js | |
| parent | 01d024d2d5652d76febb1e5f9694d336aa7a59f4 (diff) | |
[FIX] web: Controller: concurrent control panel updates
Let's assume the following scenario: in a kanban view with a
domain, remove that domain and quickly click on a record to open it
in form view. On a slow network, it may happen that the reload of
the kanban view (triggered by the domain change) returns after the
load of the form view.
Before this rev., when this happened, the form view was correctly
displayed but the control panel contained the buttons, searchview,
pager... of the kanban view.
Note that this fix is quite ugly, but it won't be necessary anymore
as soon as the control panel won't be shared between actions and
controllers, i.e. as soon as each controller will have its own
control panel.
Diffstat (limited to 'addons/web/static/src/js/views/abstract_controller.js')
| -rw-r--r-- | addons/web/static/src/js/views/abstract_controller.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/addons/web/static/src/js/views/abstract_controller.js b/addons/web/static/src/js/views/abstract_controller.js index fbddb28eab7..05100a05850 100644 --- a/addons/web/static/src/js/views/abstract_controller.js +++ b/addons/web/static/src/js/views/abstract_controller.js @@ -228,11 +228,26 @@ var AbstractController = Widget.extend(ControlPanelMixin, { var self = this; var shouldReload = (options && 'reload' in options) ? options.reload : true; var def = shouldReload ? this.model.reload(this.handle, params) : $.when(); + // we check here that the updateIndex of the control panel hasn't changed + // between the start of the update request and the moment the controller + // asks the control panel to update itself ; indeed, it could happen that + // another action/controller is executed during this one reloads itself, + // and if that one finishes first, it replaces this controller in the DOM, + // and this controller should no longer update the control panel. + // note that this won't be necessary as soon as each controller will have + // its own control panel + var cpUpdateIndex = this.cp_bus && this.cp_bus.updateIndex; return this.dp.add(def).then(function (handle) { + if (self.cp_bus && cpUpdateIndex !== self.cp_bus.updateIndex) { + return; + } self.handle = handle || self.handle; // update handle if we reloaded var state = self.model.get(self.handle); var localState = self.renderer.getLocalState(); return self.dp.add(self.renderer.updateState(state, params)).then(function () { + if (self.cp_bus && cpUpdateIndex !== self.cp_bus.updateIndex) { + return; + } self.renderer.setLocalState(localState); self._update(state); }); |
