diff --git a/addons/web/static/src/webclient/actions/client_actions.js b/addons/web/static/src/webclient/actions/client_actions.js index a6f98ea73d2..df5232314d5 100644 --- a/addons/web/static/src/webclient/actions/client_actions.js +++ b/addons/web/static/src/webclient/actions/client_actions.js @@ -55,14 +55,24 @@ function reload(env, action) { const { router } = env.services; const route = { ...router.current }; - route.hash = {}; - if (menu_id) { - route.hash.menu_id = menu_id; - } - if (action_id) { - route.hash.action = action_id; + if (menu_id || action_id) { + route.hash = {}; + if (menu_id) { + route.hash.menu_id = menu_id; + } + if (action_id) { + route.hash.action = action_id; + } } + // We want to force location.assign(...) (in router.redirect(...)) to do a page reload. + // To do this, we need to make sure that the url is different. + route.search = { ...route.search }; + if ("reload" in route.search) { + delete route.search.reload; + } else { + route.search.reload = true; + } const url = browser.location.origin + routeToUrl(route); env.bus.trigger("CLEAR-CACHES"); @@ -79,6 +89,7 @@ function home(env, action) { const { wait } = action.params || {}; const url = "/" + (browser.location.search || ""); env.services.router.redirect(url, wait); + browser.location.reload(url); } registry.category("actions").add("home", home); diff --git a/addons/web/static/tests/webclient/actions/client_action_tests.js b/addons/web/static/tests/webclient/actions/client_action_tests.js index 0ca04125dbf..32599003645 100644 --- a/addons/web/static/tests/webclient/actions/client_action_tests.js +++ b/addons/web/static/tests/webclient/actions/client_action_tests.js @@ -612,15 +612,17 @@ QUnit.module("ActionManager", (hooks) => { }); QUnit.test("test reload client action", async function (assert) { + patchWithCleanup(browser.location, { + origin: "", + hash: "#test=42", + }); + const webClient = await createWebClient({ serverData }); patchWithCleanup(webClient.env.services.router, { redirect: (url) => { assert.step(url); }, }); - patchWithCleanup(browser.location, { - origin: "", - }); await doAction(webClient, { type: "ir.actions.client", @@ -649,10 +651,10 @@ QUnit.module("ActionManager", (hooks) => { }, }); assert.verifySteps([ - "/web/tests", - "/web/tests#action=2", - "/web/tests#menu_id=1", - "/web/tests#menu_id=2&action=1", + "/web/tests?reload=true#test=42", + "/web/tests?reload=true#action=2", + "/web/tests?reload=true#menu_id=1", + "/web/tests?reload=true#menu_id=2&action=1", ]); }); });