XML Odoo 字段条件颜色格式 [英] XML Odoo field conditional color formatting

查看:206
本文介绍了XML Odoo 字段条件颜色格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在与 Odoo 和工作室合作.

I'm working with Odoo and studio.

我想使用 XML 根据所​​选值设置选择字段文本的格式.

I want to format a selection field text based on the selected value using XML.

这是我已经尝试过但根本没有效果的方法:

Here is what I have already tried but it has no effect at all:

<field name="my_status" string="Status" colors="orange:my_status == 'negotiation';green:my_status == 'signed';purple:my_status == 'internal'"/>

我也试过:

<field name="my_status" string="Status" decoration-success="my_status == 'signed'" decoration-danger="my_status == 'negociation'" decoration-muted="my_status == 'internal'"/>

你知道我缺少什么才能让它工作吗?

Do you know what I am missing for it to work?

我发现了这个,我想我不能对任何字段进行颜色格式化?https://github.com/odoo/odoo/blob/12.0/odoo/addons/base/rng/common.rng#L206

I found this, I guess I can't color format any of the fields? https://github.com/odoo/odoo/blob/12.0/odoo/addons/base/rng/common.rng#L206

推荐答案

我找到了一个解决方法:

I have found a workaround:

<field name="my_status" string="Status" style="color: red;" attrs="{'invisible': ['|',['my_status','=','signed'],['my_status','=','internal']]}"/>
<field name="my_status" string="Status" style="color: green;" attrs="{'invisible': ['|',['my_status','=','negotiation'],['my_status','=','internal']]}"/>
<field name="my_status" string="Status" style="color: purple;" attrs="{'invisible': ['|',['my_status','=','signed'],['my_status','=','negotiation']]}"/>

这篇关于XML Odoo 字段条件颜色格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆