diff --git a/addons/web/static/src/js/chrome/action_manager.js b/addons/web/static/src/js/chrome/action_manager.js index 1651e5d72d9..236d7517d04 100644 --- a/addons/web/static/src/js/chrome/action_manager.js +++ b/addons/web/static/src/js/chrome/action_manager.js @@ -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} 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; + }); }); }, /** diff --git a/addons/web/static/tests/chrome/action_manager_tests.js b/addons/web/static/tests/chrome/action_manager_tests.js index 90b3c1bf510..4d682b8994c 100644 --- a/addons/web/static/tests/chrome/action_manager_tests.js +++ b/addons/web/static/tests/chrome/action_manager_tests.js @@ -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(); + }); + }); }); });