3
votes

Good Day!, I've trying to Migrate my Odoo8 to 9 But I have an error in One2Many Grid Colors here's my code

                            <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>

and I having an Error

Uncaught Error: QWeb2 - template['ListView.rows']: Runtime Error: Error: QWeb2 - template['ListView.row']: Runtime Error: Error: NameError: name 'expired' is not defined

I found out the colors attribute is causing the error because when I remove it my grid is not causing an Error,

Is there new way in Odoo 9 to do this thanks

4

4 Answers

0
votes

This is the correct way to add color attribute in treeview. You should check your .py file where you have defined the field expired. From the error it is clear that this error is related to the definition of the field, not due to the color attribute. At runtime your filed expired is not located. That is why you are getting this error.

0
votes

For v9, colors are gone - replaced by the following decorators:

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

The formatting is dependent on the bootstrap style, and these can be combined (the colors look better when shown bold)

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

0
votes

From Odoo9 onward colour attribute as like odoo8 version is being depricated. In odoo8 we can keep color for tree view rows like this

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

This is being depricated in odoo9. In odoo9 you can only use a set of defined colors only.

In odoo9, tree views can take supplementary attributes to further customize their behavior as follows:

decoration-{$name} : This attribute allows changing the style of a row's text based on the corresponding record's attributes.

{$name} can be replaced with bf for having font weight as bold.

For example decoration-bf="condition("state=='open'")"

For italics keep as decoration-it="condition"

Odoo9 support only bootstrap contextual colors such as

bootstrap contextual colors (danger, info, muted, primary, success or warning). Bootstrap contextual colors

decoration-danger='condition' for Red

decoration-info='condition' for Blue

decoration-muted='condition' for Grey

decoration-primary='condition' for Purple

decoration-success='condition' for Green

decoration-warning='condition' for Orange

-1
votes

Actually colors are deprecated from V9. we can use like this

Decoration-danger as red and decoration-info as blue.