From 084012a29bec858ff92e76e0bbcea9eeb12616ee Mon Sep 17 00:00:00 2001 From: Lucas Perais Date: Mon, 24 Oct 2022 10:18:12 +0000 Subject: [PATCH] [FIX] web: kanban correct display of field without widget block mode Have a kanban arch with a field in display full in the kanban card template `````` Before this commit, the class that should endup in the DOM was wrongly computed. Technically, it was quoted in the owl template as if we passed it to a Component. After this commit, a field having display="full" is correctly rendered. X-original-commit: 526eb4f875ec6736d4b76da1fbdbcc99a8c33a9b Part-of: odoo/odoo#104019 --- .../src/views/kanban/kanban_compiler.js | 10 ++++++++-- .../static/tests/views/kanban_view_tests.js | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/views/kanban/kanban_compiler.js b/addons/web/static/src/views/kanban/kanban_compiler.js index 5b6363e0e75..7a2fd7e6794 100644 --- a/addons/web/static/src/views/kanban/kanban_compiler.js +++ b/addons/web/static/src/views/kanban/kanban_compiler.js @@ -38,7 +38,8 @@ export class KanbanCompiler extends ViewCompiler { doNotCopyAttributes: true, }, { - selector: ".dropdown-toggle:not(.kanban_ignore_dropdown),.o_kanban_manage_toggle_button", + selector: + ".dropdown-toggle:not(.kanban_ignore_dropdown),.o_kanban_manage_toggle_button", fn: this.compileDropdownToggler, doNotCopyAttributes: true, }, @@ -231,7 +232,9 @@ export class KanbanCompiler extends ViewCompiler { */ compileField(el, params) { let compiled; + let isSpan = false; if (!el.hasAttribute("widget")) { + isSpan = true; // fields without a specified widget are rendered as simple spans in kanban records const fieldName = el.getAttribute("name"); compiled = createElement("span", { "t-out": `record["${fieldName}"].value` }); @@ -252,7 +255,10 @@ export class KanbanCompiler extends ViewCompiler { classNames.push("o_text_bold"); } if (classNames.length > 0) { - compiled.setAttribute("class", toStringExpression(classNames.join(" "))); + const clsFormatted = isSpan + ? classNames.join(" ") + : toStringExpression(classNames.join(" ")); + compiled.setAttribute("class", clsFormatted); } const attrs = {}; for (const attr of el.attributes) { diff --git a/addons/web/static/tests/views/kanban_view_tests.js b/addons/web/static/tests/views/kanban_view_tests.js index 7ae2dc5ea12..d88ff80e6f3 100644 --- a/addons/web/static/tests/views/kanban_view_tests.js +++ b/addons/web/static/tests/views/kanban_view_tests.js @@ -361,6 +361,25 @@ QUnit.module("Views", (hooks) => { assert.containsOnce(target, ".o_kanban_record:contains(gnap)"); }); + QUnit.test("display full is supported on fields", async (assert) => { + await makeView({ + type: "kanban", + resModel: "partner", + serverData, + arch: ` + + +
+ +
+
+
`, + }); + + assert.containsOnce(target.querySelector(".o_kanban_record"), "span.o_text_block"); + assert.strictEqual(target.querySelector("span.o_text_block").textContent, "yop"); + }); + QUnit.test("basic grouped rendering", async (assert) => { assert.expect(13);