跳转到主要内容

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

项目描述

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 之前,此模块具有一个功能,允许根据字段更改线条颜色,使用 colors 属性,并在 <tree> 元素上指定字段名称。从 13.0 版本开始,colors 属性不再在树视图的 RelaxNG 架构中,因此我们不能再使用它。然后,此功能已被删除,但可以以另一种方式重新实现。

缺陷追踪器

缺陷在 GitHub Issues 上跟踪。如果在出现问题时,请检查您的错误是否已被报告。如果您首先发现它,请通过提供详细且受欢迎的 反馈 来帮助我们将其解决。

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

致谢

作者

  • Camptocamp

  • Therp BV

贡献者

其他致谢

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

  • Camptocamp

维护者

本模块由 OCA 维护。

Odoo Community Association

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

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

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

项目详情


下载文件

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

源代码分发

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

构建分发

由以下组织支持