From 43295844590bb528b3ff57c52d77d102b66bd88b Mon Sep 17 00:00:00 2001 From: momegahed Date: Thu, 12 May 2022 15:05:38 +0000 Subject: [PATCH] [FIX] web: multi lines don't work in warnings Steps to reproduce: 1- install sales 2- allow warnings on sale orders 3- set a warning w with multiple lines on sale order on customer c 4- try to add c to a sale order 5- w will be shown in one line Bug: the html is escaped and the proper styling is missing Fix: add the proper style OPW-2847660 closes odoo/odoo#94730 X-original-commit: 36546f39ca44f6d5691e3b1d8a7d1eb2da4a7b51 Signed-off-by: Aaron Bohy (aab) Signed-off-by: Mohamed Megahed Abbas Megahed SALLAM (mome) --- .../web/static/src/legacy/action_adapters.js | 2 +- .../tests/webclient/actions/legacy_tests.js | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/legacy/action_adapters.js b/addons/web/static/src/legacy/action_adapters.js index 64db441a272..9765d443cf2 100644 --- a/addons/web/static/src/legacy/action_adapters.js +++ b/addons/web/static/src/legacy/action_adapters.js @@ -26,7 +26,7 @@ const { class WarningDialog extends Component {} WarningDialog.template = xml` - +

`; WarningDialog.components = { Dialog }; diff --git a/addons/web/static/tests/webclient/actions/legacy_tests.js b/addons/web/static/tests/webclient/actions/legacy_tests.js index 294d2035be3..b237fd1ec6f 100644 --- a/addons/web/static/tests/webclient/actions/legacy_tests.js +++ b/addons/web/static/tests/webclient/actions/legacy_tests.js @@ -91,6 +91,32 @@ QUnit.module("ActionManager", (hooks) => { assert.strictEqual($(".modal-body").text(), "This is a warning..."); }); + QUnit.test("display multiline warning as modal", async function (assert) { + assert.expect(5); + let list; + patchWithCleanup(ListController.prototype, { + init() { + this._super(...arguments); + list = this; + }, + }); + + const webClient = await createWebClient({ serverData }); + await doAction(webClient, 3); + assert.containsOnce(target, ".o_list_view"); + list.trigger_up("warning", { + title: "Warning!!!", + message: "This is a warning...\nabc", + type: "dialog", + }); + await testUtils.nextTick(); + await legacyExtraNextTick(); + assert.containsOnce(target, ".o_list_view"); + assert.containsOnce(document.body, ".modal"); + assert.strictEqual($(".modal-title").text(), "Warning!!!"); + assert.strictEqual($(".modal-body")[0].innerText, "This is a warning...\nabc"); + }); + QUnit.test( "legacy crash manager is still properly remapped to error service", async function (assert) {