Skip to content
Snippets Groups Projects
Commit 206cc91a authored by Aaron Bohy's avatar Aaron Bohy
Browse files

[FIX] web: view_manager: restore internal state on switch view failure

When an error occured when switching from a view to another (e.g. switching
to a form view for an id that doesn't exist, by editing the url), active_view
and view_stack were updated even though the switch failed. The view manager
thus lost the reference to the real current active view, which couldn't be
detached anymore. This resulted in two views being displayed at the same time
if the user kept navigating through this view manager.

This is a backport of odoo/enterprise@0b1aafa6b and odoo/enterprise@8e691be.
parent 93075b6b
Branches
Tags
No related merge requests found
......@@ -156,11 +156,20 @@ var ViewManager = Widget.extend(ControlPanelMixin, {
self.searchview.do_search();
});
}
return $.when(view.created, this.active_search).then(function () {
var switched = $.when(view.created, this.active_search).then(function () {
return self._display_view(view_options, old_view).then(function () {
self.trigger('switch_mode', view_type, no_store, view_options);
});
});
switched.fail(function(e) {
if (!(e && e.code === 200 && e.data.exception_type)) {
self.do_warn(_t("Error"), view.controller.display_name + _t(" view couldn't be loaded"));
}
// Restore internal state
self.active_view = old_view;
self.view_stack.pop();
});
return switched;
},
_display_view: function (view_options, old_view) {
var self = this;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment