如何为不同的字段添加"decoration-danger"? e.g.I 如果不属于 50-100,想将我的字段更改为红色。对于其他可能是 85-95

How to add "decoration-danger" for different fields ? e.g.I want to change my field to red if it doesn't belong to 50-100. for other it might be 85-95

我正在 odoo 中制作一个应用程序,我需要将不同的字段突出显示为红色,如果它们不属于特定于他们的领域的范围。例如 bow_speed 应该介于 100 和 150 之间,否则它应该变成红色。对于 bat_speed,范围应在 40-60 之间。如果不是,则该字段应变为红色。我看到了解决方案,但它们都突出了整个树的单个字段的价值。意味着如果任何一个字段不在范围内,那么整棵树都会变成红色。我想要那个领域的具体。下面是与我上面描述的相关的代码:

<tree decoration-danger="bow_speed&lt;=150 and bow_speed&gt;=100">
    <field name="bow_speed"/>
    <field name="bat_speed"/>
</tree>

在获取单个字段的值后,我确实对整棵树使用了 "decoration-danger"。意味着如果任何一个字段不在范围内,那么整棵树都会变成红色。我想要那个字段 specific.I 试过放 "decoration-danger="bow_speed<=150 和 bow_speed>=100" 这条线在每个领域。虽然我没有得到错误但是没有输出。 我尝试了以下方法:

<tree>
    <field name="bow_speed" decoration-danger="bow_speed&lt;=150 and bow_speed&gt;=100"/>
    <field name="bat_speed" decoration-danger="bat_speed&lt;=40 and bat_speed&gt;=60"/>
</tree>

预期的结果应该是每个字段根据自己的具体情况变成红色 range.Also,我可以在表单标签中使用您的解决方案吗?

对于 FORM,你可以使用我在树中使用的方式:

<form>
    <field name="bow_speed" decoration-danger="bow_speed&lt;=150 and bow_speed&gt;=100"/>
    <field name="bat_speed" decoration-danger="bat_speed&lt;=40 and bat_speed&gt;=60"/>
</form>

对于 TREE 视图,您可以在树标记的属性中添加字段:

<tree decoration-danger="(bow_speed&lt;=150 and bow_speed&gt;=100) or
                         (bat_speed&lt;=40 and bat_speed&gt;=60")
>
    <field name="bow_speed"/>
    <field name="bat_speed"/>
</tree>