[FIX] web: kanban: add JSON to the rendering context
In legacy kanban views, one could use JSON in the arch to, e.g. parse text field values encoding data. This was no longer the case in the new implementation. This commit fixes the issue by adding it to the kanban record rendering context. However, we'll consider adding it in owl directly. Part-of: odoo/odoo#92475
This commit is contained in:
@@ -360,6 +360,10 @@ export class KanbanRecord extends Component {
|
||||
return luxon;
|
||||
}
|
||||
|
||||
get JSON() {
|
||||
return JSON;
|
||||
}
|
||||
|
||||
get read_only_mode() {
|
||||
return this.props.readonly;
|
||||
}
|
||||
|
||||
@@ -9967,4 +9967,28 @@ QUnit.module("Views", (hooks) => {
|
||||
assert.notOk(dropdown.hasAttribute("placeholder"));
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test("can use JSON in kanban template", async (assert) => {
|
||||
serverData.models.partner.records = [{ id: 1, foo: '["g", "e", "d"]' }];
|
||||
await makeView({
|
||||
type: "kanban",
|
||||
resModel: "partner",
|
||||
serverData,
|
||||
arch: `
|
||||
<kanban>
|
||||
<field name="foo"/>
|
||||
<templates>
|
||||
<t t-name="kanban-box">
|
||||
<div>
|
||||
<span t-foreach="JSON.parse(record.foo.raw_value)" t-as="v" t-key="v_index" t-esc="v"/>
|
||||
</div>
|
||||
</t>
|
||||
</templates>
|
||||
</kanban>
|
||||
`,
|
||||
});
|
||||
assert.containsOnce(target, ".o_kanban_record:not(.o_kanban_ghost)");
|
||||
assert.containsN(target, ".o_kanban_record span", 3);
|
||||
assert.strictEqual(target.querySelector(".o_kanban_record").innerText, "ged");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user