[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
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user