我有一个非常具体和简单的需求:我希望允许用户在看板视图中更改看板列的背景颜色 .

我可以通过直接覆盖QWeb KanbanView.Group模板并使用样式设置背景颜色来完成此操作,如下所示:

<template>
<t t-extend="KanbanView.Group">
          <t t-jquery="div:first-child">
this.attr("t-attf-style", "background-color: red");
        </t>
 </t>
</template>

我也可以通过更改该模板的第一个DIV的属性来执行此操作,如下所示:

<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>

然后在 manifest .py文件中添加此文件:

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

如何在QWeb模板中访问此字段的值,而不是上面示例中的“红色”?

我在舞台模型中添加了一个名为Kanban Color(字段名称“color”)的Char字段,如下所示:

Stage form

如果我这样做:

<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>

或这个:

<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>

它不起作用 . 它不打印任何东西 . 我也试过唱片 . 而不是小部件 . ...

我该怎么办?

谢谢