跳转到主要内容

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

项目描述

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.
  • 在树形视图声明中,在 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 a 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>
 ...

 With this example, the content of the field named `my_color` will be used to
 populate the `my_color` CSS value. Use a function field to return whichever
 color you want depending on the other record values. Note that this
 overrides the rest of `colors` attributes, and that you need the tree
 to load your field in the first place by adding it as invisible field.

请注意,您应该始终使用单引号为字段“options”提供属性,并且将嵌套值用双引号括起来,因为“options”是一个JSON对象。

已知问题/路线图

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

错误跟踪器

错误在GitHub Issues上进行追踪。如有问题,请先检查是否已有人报告过。如果您是第一个发现的人,请通过提供详细且受欢迎的反馈来帮助我们解决问题。

请不要直接联系贡献者询问支持或技术问题。

鸣谢

作者

  • Camptocamp

  • Therp BV

贡献者

维护者

本模块由OCA维护。

Odoo Community Association

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

本模块是GitHub上的OCA/web项目的一部分。

欢迎您贡献。要了解如何贡献,请访问https://odoo-community.org/page/Contribute

项目详情


下载文件

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

源代码分发

本发布中没有提供源代码分发文件。请参阅生成分发存档的教程。

构建分发

支持者

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