summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2019-07-19 12:04:12 +0000
committerAaron Bohy <aab@odoo.com>2019-07-19 12:07:56 +0000
commit04a600486e63397fa6295d7715613bd4b0f0acde (patch)
tree5a962e3a980dce183cd1a11310bf97651d30b294 /addons
parente266c7c98a6a4b89c13eb7eb38709cc0251ea47f (diff)
[FIX] web: remove lazyloaded controller from stack
... if the current action can't be executed. Let's assume a form view for a record with a multicompany ir.rule. If the user switches to another company, the webclient is reloaded, but he doesn't have access to that record anymore. In this case, he is redirected to the Home menu. Before this rev., when he clicked on an app in this situation, it crashed. This was due to a leftover reference of the failed action (the lazyloaded, multi-record controller) in the controller stack. closes odoo/odoo#34994 Signed-off-by: VincentSchippefilt <VincentSchippefilt@users.noreply.github.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/web/static/src/js/chrome/action_manager_act_window.js10
-rw-r--r--addons/web/static/tests/chrome/action_manager_tests.js35
2 files changed, 44 insertions, 1 deletions
diff --git a/addons/web/static/src/js/chrome/action_manager_act_window.js b/addons/web/static/src/js/chrome/action_manager_act_window.js
index 8b3ff339ded..123f41965b3 100644
--- a/addons/web/static/src/js/chrome/action_manager_act_window.js
+++ b/addons/web/static/src/js/chrome/action_manager_act_window.js
@@ -285,6 +285,7 @@ ActionManager.include({
}
var lazyViewDef;
+ var lazyControllerID;
if (lazyView) {
// if the main view is lazy-loaded, its (lazy-loaded) controller is inserted
// into the controller stack (so that breadcrumbs can be correctly computed),
@@ -294,6 +295,7 @@ ActionManager.include({
// this controller being lazy-loaded, this call is actually sync
lazyViewDef = self._createViewController(action, lazyView.type, {}, {lazy: true})
.then(function (lazyLoadedController) {
+ lazyControllerID = lazyLoadedController.jsID;
self.controllerStack.push(lazyLoadedController.jsID);
});
}
@@ -312,7 +314,13 @@ ActionManager.include({
action.controllerID = controller.jsID;
return self._executeAction(action, options);
})
- .fail(self._destroyWindowAction.bind(self, action));
+ .fail(function () {
+ if (lazyControllerID) {
+ var index = self.controllerStack.indexOf(lazyControllerID);
+ self.controllerStack = self.controllerStack.slice(0, index);
+ }
+ self._destroyWindowAction(action);
+ });
});
},
/**
diff --git a/addons/web/static/tests/chrome/action_manager_tests.js b/addons/web/static/tests/chrome/action_manager_tests.js
index 911a03d360c..b38adaeaba8 100644
--- a/addons/web/static/tests/chrome/action_manager_tests.js
+++ b/addons/web/static/tests/chrome/action_manager_tests.js
@@ -877,6 +877,41 @@ QUnit.module('ActionManager', {
actionManager.destroy();
});
+ QUnit.test('lazy loaded multi record view with failing mono record one', function (assert) {
+ assert.expect(4);
+
+ var actionManager = createActionManager({
+ actions: this.actions,
+ archs: this.archs,
+ data: this.data,
+ mockRPC: function (route, args) {
+ if (args.method === 'read') {
+ return $.Deferred().reject();
+ }
+ return this._super.apply(this, arguments);
+ },
+ });
+
+ actionManager.loadState({
+ action: 3,
+ id: 2,
+ view_type: 'form',
+ }).then(function () {
+ assert.ok(false, 'should not resolve the deferred');
+ }).fail(function () {
+ assert.ok(true, 'should reject the deferred');
+ });
+
+ assert.containsNone(actionManager, '.o_form_view');
+ assert.containsNone(actionManager, '.o_list_view');
+
+ actionManager.doAction(1);
+
+ assert.containsOnce(actionManager, '.o_kanban_view');
+
+ actionManager.destroy();
+ });
+
QUnit.test('change the viewType of the current action', function (assert) {
assert.expect(13);