diff --git a/addons/web/static/src/js/views/form/form_controller.js b/addons/web/static/src/js/views/form/form_controller.js index fc1e269d98467b2f374724ba21c58dbf72821aae..a047c1dce77a183be2fea4a5b7342ea69f8ccba5 100644 --- a/addons/web/static/src/js/views/form/form_controller.js +++ b/addons/web/static/src/js/views/form/form_controller.js @@ -574,7 +574,7 @@ var FormController = BasicController.extend({ var attrs = ev.data.attrs; if (attrs.confirm) { def = new Promise(function (resolve, reject) { - Dialog.confirm(this, attrs.confirm, { + Dialog.confirm(self, attrs.confirm, { confirm_callback: saveAndExecuteAction, }).on("closed", null, resolve); }); diff --git a/addons/web/static/tests/chrome/action_manager_tests.js b/addons/web/static/tests/chrome/action_manager_tests.js index 8f8b3eb2b2229273a0797d01bc439c09fdd34924..a8f245102eb6b1f1b9588656022772ac46efa2d6 100644 --- a/addons/web/static/tests/chrome/action_manager_tests.js +++ b/addons/web/static/tests/chrome/action_manager_tests.js @@ -3890,6 +3890,57 @@ QUnit.module('ActionManager', { actionManager.destroy(); }); + QUnit.test('can execute act_window actions in target="new"', async function (assert) { + assert.expect(5); + + this.actions.push({ + id: 999, + name: 'A window action', + res_model: 'partner', + target: 'new', + type: 'ir.actions.act_window', + views: [[999, 'form']], + }); + this.archs['partner,999,form'] = ` + <form> + <button name="method" string="Call method" type="object" confirm="Are you sure?"/> + </form>`; + this.archs['partner,1000,form'] = `<form>Another action</form>`; + + const actionManager = await createActionManager({ + actions: this.actions, + archs: this.archs, + data: this.data, + mockRPC: function (route, args) { + if (args.method === 'method') { + return Promise.resolve({ + id: 1000, + name: 'Another window action', + res_model: 'partner', + target: 'new', + type: 'ir.actions.act_window', + views: [[1000, 'form']], + }); + } + return this._super.apply(this, arguments); + }, + }); + await actionManager.doAction(999); + + assert.containsOnce(document.body, '.modal button[name=method]'); + + await testUtils.dom.click($('.modal button[name=method]')); + + assert.containsN(document.body, '.modal', 2); + assert.strictEqual($('.modal:last .modal-body').text(), 'Are you sure?'); + + await testUtils.dom.click($('.modal:last .modal-footer .btn-primary')); + assert.containsOnce(document.body, '.modal'); + assert.strictEqual($('.modal:last .modal-body').text().trim(), 'Another action'); + + actionManager.destroy(); + }); + QUnit.test('on_attach_callback is called for actions in target="new"', async function (assert) { assert.expect(4);