From 6233bcbac30b309ad916faa59e6d6cdf7f707233 Mon Sep 17 00:00:00 2001 From: "Simon Genin (ges)" Date: Mon, 26 Sep 2022 13:22:46 +0000 Subject: [PATCH] [FIX] web: markup no content helper with session storage actions When an action was retrieved from session storage, the no content helper content was not markuped. It would therefore display hmtl text on the user screen. closes odoo/odoo#101306 X-original-commit: 592b8016b8a44dc1775918e4ffbf572e9b02c50f Signed-off-by: Aaron Bohy (aab) Signed-off-by: Simon Genin (ges@odoo) --- .../src/webclient/actions/action_service.js | 3 ++ .../webclient/actions/load_state_tests.js | 41 +++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/addons/web/static/src/webclient/actions/action_service.js b/addons/web/static/src/webclient/actions/action_service.js index dee040e4191..d8c3b859d96 100644 --- a/addons/web/static/src/webclient/actions/action_service.js +++ b/addons/web/static/src/webclient/actions/action_service.js @@ -312,6 +312,9 @@ function makeActionManager(env) { // the session storage const storedAction = browser.sessionStorage.getItem("current_action"); const lastAction = JSON.parse(storedAction || "{}"); + if (lastAction.help) { + lastAction.help = markup(lastAction.help); + } if (lastAction.res_model === state.model) { if (lastAction.context) { // If this method is called because of a company switch, the diff --git a/addons/web/static/tests/webclient/actions/load_state_tests.js b/addons/web/static/tests/webclient/actions/load_state_tests.js index 75d0ed01d73..0074e9792bf 100644 --- a/addons/web/static/tests/webclient/actions/load_state_tests.js +++ b/addons/web/static/tests/webclient/actions/load_state_tests.js @@ -1069,4 +1069,45 @@ QUnit.module("ActionManager", (hooks) => { menu_id: 1, }); }); + + QUnit.test( + "'no content helper' is markuped when action is retrieved from session storage", + async function (assert) { + // for the no content helper to show, we empty the data + serverData.models.partner.records = []; + serverData.actions[4].help = "

Some nice help

"; + + patchWithCleanup(browser.sessionStorage, { + getItem(k) { + assert.step(`getItem session ${k}`); + return this._super(k); + }, + }); + + const webClient = await createWebClient({ serverData }); + + await doAction(webClient, 4); + assert.containsOnce(target, ".o_kanban_view", "should display a kanban view"); + + assert.strictEqual( + "Some nice help", + target.querySelector(".o_nocontent_help").innerText + ); + + await loadState(webClient, { + model: "partner", + view_type: "list", + }); + + assert.containsNone(target, ".o_kanban_view", "should no longer display a kanban view"); + assert.containsOnce(target, ".o_list_view", "should display a list view"); + + assert.strictEqual( + "Some nice help", + target.querySelector(".o_nocontent_help").innerText + ); + + assert.verifySteps(["getItem session current_action"]); + } + ); });