diff --git a/addons/web/static/src/webclient/actions/action_service.js b/addons/web/static/src/webclient/actions/action_service.js index 0a244b5e481..381558f4bb6 100644 --- a/addons/web/static/src/webclient/actions/action_service.js +++ b/addons/web/static/src/webclient/actions/action_service.js @@ -740,8 +740,9 @@ function makeActionManager(env) { * * @private * @param {ActURLAction} action + * @param {ActionOptions} options */ - function _executeActURLAction(action) { + function _executeActURLAction(action, options) { if (action.target === "self") { env.services.router.redirect(action.url); } else { @@ -756,6 +757,9 @@ function makeActionManager(env) { type: "warning", }); } + if (options.onClose) { + options.onClose(); + } } } @@ -1097,7 +1101,7 @@ function makeActionManager(env) { action = _preprocessAction(action, options.additionalContext); switch (action.type) { case "ir.actions.act_url": - return _executeActURLAction(action); + return _executeActURLAction(action, options); case "ir.actions.act_window": if (action.target !== "new") { await clearUncommittedChanges(env); diff --git a/addons/web/static/tests/webclient/actions/url_action_tests.js b/addons/web/static/tests/webclient/actions/url_action_tests.js index 15572b23859..e62ca8813f4 100644 --- a/addons/web/static/tests/webclient/actions/url_action_tests.js +++ b/addons/web/static/tests/webclient/actions/url_action_tests.js @@ -4,6 +4,8 @@ import { registry } from "@web/core/registry"; import { makeTestEnv } from "../../helpers/mock_env"; import { makeFakeRouterService } from "../../helpers/mock_services"; import { setupWebClientRegistries, doAction, getActionManagerServerData } from "./../helpers"; +import { patchWithCleanup } from "@web/../tests/helpers/utils"; +import { browser } from "@web/core/browser/browser"; let serverData; const serviceRegistry = registry.category("services"); @@ -33,4 +35,17 @@ QUnit.module("ActionManager", (hooks) => { }); assert.verifySteps(["/my/test/url"]); }); + + QUnit.test("execute an 'ir.actions.act_url' action with onClose option", async (assert) => { + setupWebClientRegistries(); + patchWithCleanup(browser, { + open: () => assert.step("browser open"), + }); + const env = await makeTestEnv({ serverData }); + const options = { + onClose: () => assert.step("onClose"), + }; + await doAction(env, { type: "ir.actions.act_url" }, options); + assert.verifySteps(["browser open", "onClose"]); + }); });