[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 ```<field name="fieldName" display="full" />``` 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
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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: `
|
||||
<kanban class="o_kanban_test">
|
||||
<templates><t t-name="kanban-box">
|
||||
<div>
|
||||
<field name="foo" display="full"/>
|
||||
</div>
|
||||
</t></templates>
|
||||
</kanban>`,
|
||||
});
|
||||
|
||||
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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user