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

布满荆棘的人生 2022-08-04 14:48 252阅读 0赞

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

  1. <tree string=”session List
  2. colors=”blue:state==’draft'; green:state==’confirmed’ “>
  3. <field name=”name”/>
  4. <field name=”start\_date”/>
  5. <field name=”end\_date”/>
  6. <field name=”duration”/>
  7. <field name=”seats”/>
  8. <field name=”instructor\_id”/>
  9. <field name=”course\_id”/>
  10. <field name=”attendee\_count”/>
  11. <field name=”state” />
  12. <field name=”taken\_seats” widget=”progressbar”/>
  13. </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 > 5 “

if duration is less than 15:

  • colors=”blue: duration < 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

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

in a inherith view you can change the color using attributes

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

使用and

发表评论

表情:
评论列表 (有 0 条评论,252人围观)

还没有评论,来说两句吧...

相关阅读

    相关 QT设置QLabel字体颜色

    QT设置QLabel中字体的颜色 其实,这是一个比较常见的问题。大致有几种做法:一是使用setPalette()方法;二是使用样式表;三是可以使用QStyle;四是可

    相关 状态栏字体颜色设置

    根据不同的主题设置状态栏的字体颜色,主要有以下几种实现方法。 > 注意:状态栏的字体颜色分两种,一种是黑色,另一种是白色。 步骤1 设置`info.plist`中的属性