[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) <aab@odoo.com>
Signed-off-by: Simon Genin (ges@odoo) <ges@odoo.com>
This commit is contained in:
Simon Genin (ges)
2022-09-27 17:11:34 +02:00
parent f23399db1d
commit 6233bcbac3
2 changed files with 44 additions and 0 deletions
@@ -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
@@ -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 = "<p>Some nice help</p>";
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"]);
}
);
});