在openerp的tree视图中设置字体及颜色
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:
<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 > 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
<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
还没有评论,来说两句吧...