[FIX] web: doAction always resolved with the action
Before this commit, doAction returns a deferred that is resolved when the action is performed (the exact moment depends of the type of the action). However, the deferred was not resolved with the action. This is misleading, hence a traceback in the web_client when clicking on 'Run JS Tests' in debug mode (enterprise): after doAction, the web_client should hide the home_menu depending on the type of the action. With this commit, any doAction returns a deferred that is resolved with the performed action.
This commit is contained in:
@@ -140,9 +140,10 @@ var ActionManager = Widget.extend({
|
||||
* is useful when we come from a loadState())
|
||||
* @param {boolean} [options.replace_last_action=false] set to true to
|
||||
* replace last part of the breadcrumbs with the action
|
||||
* @return {Deferred} resolved when the action is loaded and appended to the
|
||||
* DOM ; rejected if the action can't be executed (e.g. if doAction has
|
||||
* been called to execute another action before this one was complete).
|
||||
* @return {$.Deferred<Object>} resolved with the action when the action is
|
||||
* loaded and appended to the DOM ; rejected if the action can't be
|
||||
* executed (e.g. if doAction has been called to execute another action
|
||||
* before this one was complete).
|
||||
*/
|
||||
doAction: function (action, options) {
|
||||
var self = this;
|
||||
@@ -179,7 +180,9 @@ var ActionManager = Widget.extend({
|
||||
|
||||
self._preprocessAction(action, options);
|
||||
|
||||
return self._handleAction(action, options);
|
||||
return self._handleAction(action, options).then(function () {
|
||||
return action;
|
||||
});
|
||||
});
|
||||
},
|
||||
/**
|
||||
|
||||
@@ -2525,6 +2525,35 @@ QUnit.module('ActionManager', {
|
||||
|
||||
actionManager.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('doAction resolved with an action', function (assert) {
|
||||
assert.expect(4);
|
||||
var done = assert.async();
|
||||
|
||||
this.actions.push({
|
||||
id: 21,
|
||||
name: 'A Close Action',
|
||||
type: 'ir.actions.act_window_close',
|
||||
});
|
||||
|
||||
var actionManager = createActionManager({
|
||||
actions: this.actions,
|
||||
archs: this.archs,
|
||||
data: this.data,
|
||||
});
|
||||
|
||||
actionManager.doAction(21).then(function (action) {
|
||||
assert.ok(action, "doAction should be resolved with an action");
|
||||
assert.strictEqual(action.id, 21,
|
||||
"should be resolved with correct action id");
|
||||
assert.strictEqual(action.name, 'A Close Action',
|
||||
"should be resolved with correct action name");
|
||||
assert.strictEqual(action.type, 'ir.actions.act_window_close',
|
||||
"should be resolved with correct action type");
|
||||
actionManager.destroy();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user