Skip to Content
Menu
This question has been flagged

Hello all,

I have a very specific and simple need: I want to allow the user to change a kanban column's background color, in the kanban view.

I can do this by directly overriding the QWeb KanbanView.Group template and setting a background color using style, like this:

"

<template>

<t t-extend="KanbanView.Group">

          <t t-jquery="div:first-child">

this.attr("t-attf-style", "background-color: red");

        </t>

 </t>

</template>

"

I can also do this by changing the attributes of the first DIV of that template like this:

"

<template>

<t t-extend="KanbanView.Group">

          <t t-jquery="div:first-child" t-operation="attributes">

        <attribute name="style">background-color: red</attribute>

        </t>

 </t>

</template>

"

And then adding this file in the __manifest__.py file:

    'qweb': ['static/src/xml/kanban.xml'],


How can I access this field's value in the QWeb template, instead of "red" in the examples above?

I have added a Char field called Kanban Color (field name "color") to the stage model like this:




If I do this:
"
<template>
<t t-extend="KanbanView.Group">
          <t t-jquery="div:first-child" t-operation="attributes">
        <attribute name="style">background-color: <t t-esc="widget.color"/></attribute>
        </t>
 </t>
</template>
"
or this:
"
<template>
<t t-extend="KanbanView.Group">
          <t t-jquery="div:first-child" t-operation="attributes">
        <attribute name="style">background-color: #{widget.color}</attribute>
        </t>
 </t>
</template>
"
It doesn't work. It doesn't print anything. I have also tried with record. instead of widget. ...

How should I do it?

Thanks
Avatar
Discard
Related Posts Replies Views Activity
1
Oct 22
21681
1
Jul 22
1460
1
Jul 20
3753
4
Apr 16
10911
2
Mar 15
14581