【问题标题】:How to apply multiple formating on single field in xml odoo?如何在 xml odoo 中的单个字段上应用多种格式?
【发布时间】:2019-09-25 12:14:32
【问题描述】:

如果选择字段中的值为“打开”、“待处理”和“已解决”,我想根据我的字段值应用格式设置,颜色应分别为“红色”、“蓝色”和“灰色”。

<field name = 'status' widget="selection" attrs="{'invisible':[('type','=','open')]}" style="color:red;" />

【问题讨论】:

    标签: xml formatting odoo


    【解决方案1】:
    <field name = 'status' widget="selection" decoration-danger="status=='open'" decoration-info="status=='pending'" decoration-muted="status=='solved'"/>
    

    它对我有用。

    【讨论】:

    • 这会改变选定的值还是整个字段?
    • 不,只是即将到来的值格式将根据此更改。即将到来的值可能是 'open'、'pending' 或 'solved' 无论值只是该单词的格式会改变。
    • 投票比我的解决方案更容易,但您仅限于颜色列表
    • @CharifDZ 你是对的,这是唯一的限制。
    【解决方案2】:

    您可以使用t-att-style 属性代替style

    例如:

    t-att-style="'color: #f00;' if type == 'open' else ('color: #00f;' if type == 'pending' else 'color: #696969;')"

    试试这个(可能会有一些变化)

    【讨论】:

    • @adamStrauss 不工作?看看这个模块,apps.odoo.com/apps/modules/11.0/web_tree_dynamic_colored_field,想想会有帮助。
    • 我想如果我没记错的话,你是在给我一些其他模块文档的参考。如果我想要那个功能,我必须安装那个模块,对吗?如果是,那么抱歉我不能,因为我想要它没有任何其他模块安装。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-23
    • 1970-01-01
    • 1970-01-01
    • 2021-05-18
    • 1970-01-01
    相关资源
    最近更新 更多