树视图中的颜色Odoo 9 ERROR

时间:2016-07-29 08:51:46

标签: openerp odoo-9

美好的一天! 我试图将我的Odoo8迁移到9但是我在One2Many网格颜色中出错了 这是我的代码

                            <group>
                            <data>
                                <field name="employee_documents" string ="">
                                    <tree colors = "red:expired=='EXP'">
                                        <field name="document"/>
                                        <field name="document_number"/>
                                        <field name="date_issued"/>
                                        <field name="date_expiry"/>
                                        <field name="issuing_authority"/>
                                        <field name="place_ofissue"/>
                                        <field name="expired" />
                                    </tree>                                 
                                </field>
                            </data>
                        </group>

我有错误

  

未捕获错误:QWeb2 - 模板[&#39; ListView.rows&#39;]:运行时错误:错误:QWeb2 - 模板[&#39; ListView.row&#39;]:运行时错误:错误:NameError:姓名&#39;已过期&#39;未定义

我发现colors属性导致错误,因为当我删除它时,我的网格不会导致错误,

Odoo 9中是否有新的方式来做这件事,谢谢

4 个答案:

答案 0 :(得分:0)

这是在树视图中添加颜色属性的正确方法。您应该检查已定义字段.py的{​​{1}}文件。 从错误中可以清楚地看出,该错误与字段的定义有关,而不是由于颜色属性。在运行时,您找不到归档expired。这就是你得到这个错误的原因。

答案 1 :(得分:0)

对于v9,颜色消失 - 由以下装饰器替换:

decoration-bf - shows the line in BOLD

decoration-it - shows the line in ITALICS

decoration-danger - shows the line in LIGHT RED

decoration-info - shows the line in LIGHT BLUE

decoration-muted - shows the line in LIGHT GRAY

decoration-primary - shows the line in LIGHT PURPLE

decoration-success - shows the line in LIGHT GREEN

decoration-warning - shows the line in LIGHT BROWN

格式取决于引导程序样式,可以组合使用(显示粗体时颜色看起来更好)

https://www.odoo.com/fr_FR/forum/aide-1/question/set-color-in-tree-view-based-on-task-stage-94556

答案 2 :(得分:0)

从Odoo9开始,颜色属性就像odoo8版本一样正在被删除。 在odoo8中,我们可以像这样保存树视图行的颜色

<tree string="tree_view_BT" colors="red:state == 'inact'">

这是在odoo9中被删除的。在odoo9中,您只能使用一组定义的颜色。

  

在odoo9中,树视图可以采用补充属性来进一步自定义其行为,如下所示:

     

装饰 - {$ name}:此属性允许根据相应的记录属性更改行文字的样式。

{$ name} 可以替换为 bf ,因为字体粗细为粗体。

例如 decoration-bf =&#34;条件(&#34;州==&#39;打开&#39;&#34;)&#34;

对于斜体保持装饰 - 它=&#34;条件&#34;

Odoo9仅支持引导上下文颜色,例如

  

bootstrap上下文颜色(危险,信息,静音,主要,成功或   警告)。   Bootstrap contextual colors

装饰-危险=&#39;条件&#39; 红色

装饰-信息=&#39;条件&#39;对于蓝色

装饰-静音=&#39;条件&#39; 灰色

装饰基色=&#39;条件&#39;对于紫色

装饰-成功=&#39;条件&#39; 绿色

装饰预警=&#39;条件&#39;对于橙色

答案 3 :(得分:-1)

实际上,V9不推荐使用颜色。我们可以像这样使用

装饰 - 危险为红色,装饰信息为蓝色。

相关问题