从Odoo9开始,视图层就采用了bootstrap主题,属性写法如下:
decoration-{$name} = 值 来对每条记录添加行的样式
{$name}可以是 bf(font-weight:bold), it(font-style:italic),或 bootstrap contextual
color(danger,info,primary,success,warning)值是一个python表达式,表达式可以引用到
tree关联记录的子弹 以及uid(当前用户 int) current_date(当前时间 格式yyyy-MM-dd字符串)。
editable = top 或者 bottom 设置行内编辑功能(top从上方/bottom下方)
<!--<和>是转义字符,分别是小于和大于的意思-->
<tree decoration-success="duration<5" decoration-danger="duration>15">
<field name="name"/>
<!-- invisible:设置隐藏 -->
<field name="duration" invisible="1"/>
</tree>
这里是对模型中的 duration字段值进行判断。其中success、danger分别是绿色、红色,是bootstrap定义的内容。
想要了解html/xml转义字符可以参考: HTML转义字符对照表
python模型代码片断:
xml:
效果图(判断字段列为’持续时间’):
再来设置一下行内编辑:
效果: