允许您动态为树视图上的字段上色
odoo12-addon-web-tree-dynamic-colored-field的Python项目详细描述
此模块旨在添加对树视图中字段动态着色的支持 根据记录中的数据。
它为字段提供与colors属性语法相似的属性 在树标记中。
此外,它在树标记的colors上提供了一个color_field属性来使用 字段的颜色值。
功能
- 将字段的options上的属性bg_color添加到树视图中单元格的颜色背景中
- 在字段的options上添加属性fg_color以更改树视图中单元格的文本颜色
- 在树元素的colors上添加属性color_field以用作颜色
目录
用法
在树视图声明中,将options='{"bg_color": "red: customer==True"}属性放入field标记:
... <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.
在树视图声明中,将options='{"fg_color": "white:customer == True"}'属性放入field标记:
... <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.
在树视图声明中,使用tree标记中的options='"color_field": "my_color"'属性:
... <field name="arch" type="xml"> <tree string="View name" colors="color_field: my_color" > ... <field name="my_color" invisible="1"/> ... </tree> </field> ...
如果要使用多个颜色,可以使用“;”分割属性:
options='{"fg_color": "red:red_color == True; green:green_color == True"}'
示例:
... <fieldname="arch"type="xml"><treestring="View name"> ... <fieldname="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对象。
学分
贡献者
- 达米恩·克里尔damien.crier@camptocamp.com>;
- 霍尔格·布鲁恩hbrunn@therp.nl>;
- 阿泰姆·克斯特尤克(Artem Kostyuk)a.kostyuk@mobilunity.com>;
- guewen baconnier<;guewen.baconnier@camptocamp.com>;
维护人员
此模块由OCA维护。
oca,或odoo社区协会,是一个非营利性组织 任务是支持odoo特性和 促进其广泛应用。
此模块是github上OCA/web项目的一部分。
欢迎您的贡献。要了解如何访问https://odoo-community.org/page/Contribute。