在openerp的tree视图中设置字体及颜色

本文介绍如何在Odoo中使用tree元素的colors属性为记录着色,并可根据不同条件改变颜色。此外,还介绍了如何使用fonts属性来设置记录的字体样式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Colors

Use the colors attribute on the tree element to colorize records based on some conditions. 

Example, to colorize session list depending on it’s state:

Image001 

                <tree string=”session List”

                                colors=”blue:state==’draft'; green:state==’confirmed’ “>

                     <field name=”name”/>

                     <field name=”start_date”/>

                     <field name=”end_date”/>

                     <field name=”duration”/>

                     <field name=”seats”/>

                     <field name=”instructor_id”/>

                     <field name=”course_id”/>

                     <field name=”attendee_count”/>

                     <field name=”state” />

                     <field name=”taken_seats” widget=”progressbar”/>

                 </tree>

 

Don’t forget to include the conditional field also in the field list, otherwise it will not work.

Some conditional expresions that can be used on the colors attribute:

If state in either ‘confirmed’, ‘done’, ‘waiting’ :

  • colors=”blue: state in (‘confirmed’, ‘done’, ‘waiting’)”

if state is equal to ‘draft’:

  • colors=”blue: state==’draft’ “

if duration is greater than 5:          

  • colors=”blue: duration &gt; 5 “

if duration is less than 15:  

  • colors=”blue: duration &lt; 15 “

multiple conditions:

  • colors=”blue: state in (‘confirmed’, ‘done’, ‘waiting’) ; red: state==’draft’”

 

Fonts

There is also fonts attribute to set the font of the records, for example to set bold fonts on records with message_unread is True:

  • fonts=”bold:message_unread==True”
来自:http://vitraining.com/colorize-and-fonts-in-tree-view-record-in-openerp/

另外使用视图的继承方法可以修改视图的color

The color can be changed with this code

<tree colors="red:state='draft'">

in a inherith view you can change the color using attributes

<tree position="attributes">
    <attribute name="colors">red:state='draft'</attribute>
</tree>


使用and

<tree colors="grey:state == 'cancel';red:(state not in ('cancel','done')) and date &gt; current_date" string="Moves" editable="top">

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值