[FIX] web: restore /apps/<app> controller

Since JS refactoring of ActionManager at 32b8cec536, the /apps/<app> controller
was not working anymore as the refactoring dropped the support of `sa` as URL
state.

closes odoo/odoo#33679

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
Romain Derie
2019-05-27 11:44:08 +00:00
parent 37bca6ae50
commit e9350993ca
2 changed files with 40 additions and 4 deletions
@@ -47,7 +47,10 @@ ActionManager.include({
* @param {string} [state.view_type]
*/
loadState: function (state) {
var callersArguments = arguments;
var self = this;
var action;
var def;
var options = {
clear_breadcrumbs: true,
pushState: false,
@@ -102,11 +105,20 @@ ActionManager.include({
action = lastAction;
options.viewType = state.view_type;
}
} else if (state.sa) {
def = this._rpc({
route: '/web/session/get_session_action',
params: {key: state.sa},
}).then(function (sessionAction) {
action = sessionAction;
});
}
if (action) {
return this.doAction(action, options);
}
return this._super.apply(this, arguments);
return $.when(def).then(function () {
if (action) {
return self.doAction(action, options);
}
return self._super.apply(self, callersArguments);
});
},
//--------------------------------------------------------------------------
@@ -1135,6 +1135,30 @@ QUnit.module('ActionManager', {
actionManager.destroy();
});
QUnit.test('state.sa should load action from session', function (assert) {
assert.expect(1);
var actionManager = createActionManager({
actions: this.actions,
archs: this.archs,
data: this.data,
mockRPC: function (route, args) {
if (route === '/web/session/get_session_action') {
return $.when(1);
}
return this._super.apply(this, arguments);
},
});
actionManager.loadState({
sa: 1,
});
assert.strictEqual(actionManager.$('.o_kanban_view').length, 1,
"should have rendered a kanban view");
actionManager.destroy();
});
QUnit.module('Concurrency management');
QUnit.test('drop previous actions if possible', function (assert) {