ช่วยเหลือ

0

Change kanban column's background color in Odoo 11

Avatar
Fernando Gomes

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