Odoo11:将属性添加到现有看板视图元素

问题描述

我正在与Odoo 11合作,并且继承了product.template kanban view。我想使用以下类oe_kanban_global_click向div元素添加一个类。我已经使用了以下两个代码段,但是都没有用(没有添加到div元素中)。

<xpath expr="//div[@class='oe_kanban_global_click']" position="attributes">
     <attribute name="t-attf-class" separator=" " add="oe_kanban_color_#{record.x_alert_qty_reached.raw_value}"/>
</xpath>

<xpath expr="//div[@class='oe_kanban_global_click']" position="attributes">
      <attribute name="t-attf-class">oe_kanban_color_#{record.x_alert_qty_reached.raw_value}"</attribute>
</xpath>

请帮忙吗?

解决方法

尝试将class属性设置为空字符串。

以下示例继承产品模板看板视图以更改class属性:

<record id="product_template_kanban_view" model="ir.ui.view">
    <field name="name">Product.template.product.kanban</field>
    <field name="model">product.template</field>
    <field name="inherit_id" ref="product.product_template_kanban_view"/>
    <field name="arch" type="xml">
        <xpath expr="//templates" position="before">
            <field name="x_alert_qty_reached"/>
        </xpath>
        <xpath expr="//div[@class='oe_kanban_global_click']" position="attributes">
            <attribute name="class"></attribute>
            <attribute name="t-attf-class">oe_kanban_color_#{record.x_alert_qty_reached.raw_value} oe_kanban_card oe_kanban_global_click</attribute>
        </xpath>
    </field>
</record>

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...