diff options
| author | Lucas Perais (lpe) <lpe@odoo.com> | 2018-06-11 12:08:19 +0200 |
|---|---|---|
| committer | Lucas Perais (lpe) <lpe@odoo.com> | 2018-06-21 13:13:36 +0200 |
| commit | f0efcbe592319fdcb14e2342a14257580ed2f45d (patch) | |
| tree | a3f2ecaa0d3cc90837048e58cf07f7470fd381e8 /addons/web | |
| parent | 226230952a9c42a79492002749d81a9ca3cae51f (diff) | |
[FIX] web: actions target=new should transmit their on_close
Have an action that opens a dialog, with a specific callback
to execute when the dialog closes
In the dialog, have a button linked to an action that opens
another dialog in target = new
Close this 2nd dialog
Before this commit, the callback was not executed
After this commit the callback is executed
OPW 1853136
closes #25180
Diffstat (limited to 'addons/web')
| -rw-r--r-- | addons/web/static/src/js/chrome/action_manager.js | 5 | ||||
| -rw-r--r-- | addons/web/static/tests/chrome/action_manager_tests.js | 28 |
2 files changed, 32 insertions, 1 deletions
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); |
