Skip to Content
Menu
v 11.0 v 12.0 Third Party 274
Download for v 12.0 Deploy on Odoo.sh
Availability
Odoo Online
Odoo.sh
On Premise
Lines of code 102
Technical Name web_widget_colored_field
LicenseLGPL-3
Websitehttps://github.com/cognichain/odoo-basic-extension
Versions 11.0 12.0
You bought this module and need support? Click here!

[![License](https://img.shields.io/badge/license-LGPL--3.0-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0-standalone.html)

# Colorize field in form views

这个模块添加了根据表达式动态渲染字段颜色的能力支持,可用的字段类型如下:

  • Char
  • Float
  • Integer
  • Selection

## Features

  • 添加属性 color 到表单字段 fieldoptions 中以在表达式 expr 成立时渲染该字段的颜色
  • 添加属性 title 到表单字段 fieldoptions 中以在表达式 expr 成立时为该字段添加 tooltip 显示 title 中的内容

## Usage

  • 在定义表单视图中的字段时,添加属性 options="{'color': 'red', 'expr': 'cost != price'}"field 标签内:

```xml <!-- 在该例中,当 cost 和 price 不相等时,字段 cost 将会以红色字体显示其值 --> ... <field name="arch" type="xml">

<form string="View name">
... <field name="cost" options="{'color': 'red', 'expr': 'cost != price'}"/> <field name="price"/>

</form>

</field> ... ```

  • 在定义表单视图中的字段时,添加属性 options="{'color': 'blue', 'title': 'Same!', 'expr': 'a != b'}"field 标签内:

```xml <!-- 在该例中,当 a 和 b 相等时,字段 a 将会以蓝色字体显示其值,且当鼠标指针停留在字段 a 上时会弹出一个 tooltip 并显示 title 中的内容 --> ... <field name="arch" type="xml">

<form string="View name">
... <field name="a" options="{'color': 'blue', 'title': 'Same!', 'expr': 'a == b'}"/> <field name="b"/>

</form>

</field> ... ```

属性 options 中的 title 是非必需的,可以仅在需要增加提示信息时添加该属性;其中颜色属性 color 可以是 CSS 中的颜色关键字,也可以是十六进制表示的颜色值(如白色 #FFFFFF)。

## Bug Tracker

如果遇到任何问题,欢迎在 [GitHub Issues](https://github.com/cognichain/odoo-basic-extension/issues) 进行反馈。

## Credits

### Contributors

### Maintainer

<img src="./static/description/icon.png" width="20%" alt="深圳市知链科技有限公司" />

该模块由深圳市知链科技有限公司开发及维护。

Please log in to comment on this module

  • The author can leave a single reply to each comment.
  • This section is meant to ask simple questions or leave a rating. Every report of a problem experienced while using the module should be addressed to the author directly (refer to the following point).
  • If you want to start a discussion with the author, please use the developer contact information. They can usually be found in the description.
Please choose a rating from 1 to 5 for this module.