跳转到主要内容

允许您根据记录中的数据动态着色树视图中的字段

项目描述

Beta License: AGPL-3 OCA/web Translate me on Weblate Try me on Runboat

本模块旨在根据记录中的数据在树视图中动态着色字段

功能

  • 在字段“options”上添加属性“bg_color”,用于着色树视图中的单元格背景

  • 在字段“options”上添加属性“fg_color”,用于更改树视图中的单元格文本颜色

目录

使用方法

  • 在树视图声明中,在“field”标签中放置 options='{"bg_color": "red: customer==True"} 属性

    ...
    <field name="arch" type="xml">
        <tree string="View name">
            ...
            <field name="name" options='{"bg_color": "red: customer == True"}'/>
            ...
        </tree>
    </field>
    ...
    
    With this example, column which renders 'name' field will have its **background** colored in red on customer records.
  • 在树视图声明中,在“field”标签中放置 options='{"fg_color": "white:customer == True"}' 属性

    ...
    <field name="arch" type="xml">
        <tree string="View name">
            ...
            <field name="name" options='{"fg_color": "white:customer == True"}'/>
            ...
        </tree>
    </field>
    ...
    
    With this example, column which renders 'name' field will have its **text** colored in white on customer records.
  • 如果需要使用多个颜色,可以使用“;”分隔属性

options='{"fg_color": "red:red_color == True; green:green_color == True"}'

示例

...
 <field name="arch" type="xml">
     <tree string="View name">
         ...
         <field name="name" options='{"fg_color": "red:red_color == True; green:green_color == True"}'/>
         ...
     </tree>
 </field>
 ...
  • 也可以使用字符串… 在树视图声明中,在“field”标签中放置 options="{'fg_color': 'green:customer_state == \'success\''}" 属性

    ...
    <field name="arch" type="xml">
        <tree string="View name">
            ...
            <field name="name" options="{'fg_color': 'green:customer_state == \'success\''}"/>
            ...
        </tree>
    </field>
    ...

请注意,您可以使用单引号或普通引号。如果选项的声明不符合JSON格式,则选项字符串将使用py.eval()进行评估

已知问题/路线图

  • 在版本13.0之前,此模块具有一个功能,可以根据字段更改线条的颜色,使用名为colors的属性,并在<tree>元素上指定字段名称。从13.0版本开始,colors属性不再包含在树视图的RelaxNG模式中,因此我们不能再使用它。该功能已被删除,但可以以其他方式重新实现。

  • 从版本17.0开始,着色被写入(td)元素的style属性

错误跟踪器

错误在GitHub Issues上跟踪。在遇到问题时,请检查您的错误是否已被报告。如果您是第一个发现的人,请提供详细的反馈,以帮助我们解决问题。

请不要直接联系贡献者以获取支持或技术问题的帮助。

致谢

作者

  • Camptocamp

  • Therp BV

贡献者

其他贡献

此模块的开发得到了以下机构的财务支持

  • Camptocamp

  • Versada

维护者

此模块由OCA维护。

Odoo Community Association

OCA,即Odoo社区协会,是一个非营利组织,其使命是支持Odoo功能的协作开发并推广其广泛应用。

此模块是OCA/web项目在GitHub上的一个部分。

欢迎您贡献力量。有关如何贡献的信息,请访问https://odoo-community.org/page/Contribute

项目详情


下载文件

下载您平台上的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源代码发行版

此版本没有提供源代码发行版文件。有关生成发行版存档的教程,请参阅生成发行版存档

构建的发行版

由以下机构支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面