diff options
| author | Elkasitu <adt@odoo.com> | 2017-07-13 11:13:57 +0200 |
|---|---|---|
| committer | Elkasitu <adt@odoo.com> | 2017-07-13 13:10:30 +0200 |
| commit | 0c496136a9e3eb4dd779e0ac019f1ed9341df152 (patch) | |
| tree | 59e3bebd28bf23113079093a82f4eabe7e048806 /addons/web/static/src/js | |
| parent | 60ee6bbda51a960e3812a70d82854929c2e22081 (diff) | |
[FIX] web: Discard from form view to form view
Clicking on the discard button in a form view whose previous view is
another form view wouldn't do anything.
This is fixed by making the view_manager trigger_up a history_back event
and then the history_back callback will handle cases in which there is
only one view and only one action, which used to be rejected
Diffstat (limited to 'addons/web/static/src/js')
| -rw-r--r-- | addons/web/static/src/js/chrome/action_manager.js | 18 | ||||
| -rw-r--r-- | addons/web/static/src/js/chrome/view_manager.js | 10 | ||||
| -rw-r--r-- | addons/web/static/src/js/views/basic/basic_controller.js | 2 |
3 files changed, 13 insertions, 17 deletions
diff --git a/addons/web/static/src/js/chrome/action_manager.js b/addons/web/static/src/js/chrome/action_manager.js index 94812302602..4dfc299e428 100644 --- a/addons/web/static/src/js/chrome/action_manager.js +++ b/addons/web/static/src/js/chrome/action_manager.js @@ -420,16 +420,20 @@ var ActionManager = Widget.extend({ return this.inner_widget; }, history_back: function() { - var nb_views = this.inner_action.get_nb_views(); - if (nb_views > 1) { + var nbViews = this.inner_action.get_nb_views(); + if (nbViews > 1) { // Stay on this action, but select the previous view - return this.select_action(this.inner_action, nb_views - 2); + return this.select_action(this.inner_action, nbViews - 2); } - if (this.action_stack.length > 1) { + var nbActions = this.action_stack.length; + if (nbActions > 1) { // Select the previous action - var action = this.action_stack[this.action_stack.length - 2]; - nb_views = action.get_nb_views(); - return this.select_action(action, nb_views - 1); + var action = this.action_stack[nbActions - 2]; + nbViews = action.get_nb_views(); + return this.select_action(action, nbViews - 1); + } + else if (nbActions === 1 && nbViews === 1) { + return this.select_action(this.action_stack[0], 0); } return $.Deferred().reject(); }, diff --git a/addons/web/static/src/js/chrome/view_manager.js b/addons/web/static/src/js/chrome/view_manager.js index eeccd9f1085..fcd823f440a 100644 --- a/addons/web/static/src/js/chrome/view_manager.js +++ b/addons/web/static/src/js/chrome/view_manager.js @@ -636,18 +636,10 @@ var ViewManager = Widget.extend(ControlPanelMixin, { * will call this very view manager to activate the previous view. * @todo: directly switch to previous view * - * A special case is done in the case that there is no previous view. When - * that happens, we simply rerender the current view. - * * @private */ _onSwitchToPreviousView: function () { - if (this.view_stack.length === 1) { - var currentView = this.view_stack[0].controller; - currentView.update({}, {reload: false}); - } else { - this.do_action('history_back'); - } + this.trigger_up('history_back'); } }); diff --git a/addons/web/static/src/js/views/basic/basic_controller.js b/addons/web/static/src/js/views/basic/basic_controller.js index 82dc6f90d26..cc72816a85d 100644 --- a/addons/web/static/src/js/views/basic/basic_controller.js +++ b/addons/web/static/src/js/views/basic/basic_controller.js @@ -250,7 +250,7 @@ var BasicController = AbstractController.extend(FieldManagerMixin, { on_fail: function (reason) { reload().always(function() { def.reject(reason); - }) + }); }, on_success: def.resolve.bind(def), }); |
