diff --git a/addons/web/static/src/js/chrome/action_manager.js b/addons/web/static/src/js/chrome/action_manager.js index ecd1d89ea9c..97c68e2474d 100644 --- a/addons/web/static/src/js/chrome/action_manager.js +++ b/addons/web/static/src/js/chrome/action_manager.js @@ -388,10 +388,13 @@ var ActionManager = Widget.extend({ } return this._startController(controller).then(function (controller) { + var prevDialogOnClose; if (self.currentDialogController) { + prevDialogOnClose = self.currentDialogController.onClose; self._closeDialog(true); } + controller.onClose = prevDialogOnClose || options.on_close; var dialog = new Dialog(self, _.defaults({}, options, { buttons: [], dialogClass: controller.className, @@ -402,7 +405,7 @@ var ActionManager = Widget.extend({ self._removeAction(action.jsID); self.currentDialogController = null; if (silent !== true) { - options.on_close(); + controller.onClose(); } }); controller.dialog = dialog; diff --git a/addons/web/static/tests/chrome/action_manager_tests.js b/addons/web/static/tests/chrome/action_manager_tests.js index 84e939de6da..e057db97f7a 100644 --- a/addons/web/static/tests/chrome/action_manager_tests.js +++ b/addons/web/static/tests/chrome/action_manager_tests.js @@ -93,6 +93,9 @@ QUnit.module('ActionManager', { name: 'A Client Action', tag: 'ClientAction', type: 'ir.actions.client', + }, { + id: 10, + type: 'ir.actions.act_window_close', }]; this.archs = { @@ -2850,6 +2853,31 @@ QUnit.module('ActionManager', { actionManager.destroy(); }); + QUnit.test('chained action on_close', function (assert) { + assert.expect(3); + + function on_close() { + assert.step('Close Action'); + }; + + var actionManager = createActionManager({ + actions: this.actions, + archs: this.archs, + data: this.data, + }); + actionManager.doAction(5, {on_close: on_close}); + + // a target=new action shouldn't activate the on_close + actionManager.doAction(5); + assert.verifySteps([]); + + // An act_window_close should trigger the on_close + actionManager.doAction(10); + assert.verifySteps(['Close Action']); + + actionManager.destroy(); + }); + QUnit.test('footer buttons are moved to the dialog footer', function (assert) { assert.expect(3);