This question has been flagged
9 Replies
15892 Views

I am trying to set different colors of tasks in tree view based on stage: ie. blue for open tasks, green for completed tasks.

Stages:
Open (id:1),
Completed (id:6),
Cancelled (id:7)


When i try this (just to check)

colors="blue:stage_id != 1

it turns every task blue including the Open tasks! So, I am not using the correct stage_id for this to work?


Here is the full xml:

<?xml version="1.0"?>
    <tree default_order="x_start_date asc" fonts="bold:message_unread==True" colors="blue:stage_id != 1;" string="Tasks">
        <field name="message_unread" invisible="1"/>
        <field name="sequence" invisible="not context.get('seq_visible', False)"/>
        <field name="name"/>
        <field name="project_id" invisible="context.get('user_invisible', False)" string="PO#"/>
        <field name="user_id" invisible="context.get('user_invisible', False)"/>
        <field name="delegated_user_id" invisible="context.get('show_delegated', True)"/>
        <field name="total_hours" invisible="1"/>
        <field name="planned_hours" invisible="context.get('set_visible',False)" groups="project.group_time_work_estimation_tasks"/>
        <field name="effective_hours" widget="float_time" sum="Spent Hours" invisible="1"/>
        <field name="remaining_hours" widget="float_time" sum="Remaining Hours" on_change="onchange_remaining(remaining_hours,planned_hours)" invisible="context.get('set_visible',False)" groups="project.group_time_work_estimation_tasks"/>
        <field name="date_deadline" invisible="context.get('deadline_visible',True)"/>
        <field name="stage_id" invisible="context.get('set_visible',False)" string="Task Status"/>
 </tree>

Avatar
Discard
Author

@anonymous: Well, i think i already have that in this line: Do i need to have any other field for this?

Author

@Ray Carnes: I am using using V8 community version

Hello Zohair,

Please Make Sure to add field "id' in tree view (make invisible if not needed)

Example:

    <tree colors= "blue:stage_id != 1;"  string="Tasks">

Thanks

Best Answer

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

Avatar
Discard

Thanks Ray, but what happens if i want to create my custom colors?

But Odoo's designers had a Color Summit and spent hours deciding those were the only colors that would look with the new design. You can't second guess them and start using your own!!! Why would you want your own colors? Why go against all of the planning and hard work to make sure Odoo looks great and will never clash with ill chosen color combinations? What you speak of is heracy. :)

how to apply these colors in xml

Sorry my late answer Ray, it is not heresy, lol, the thing is i also used Odoo as a framework, and there are business objects where i need a lot of color to differentiate the different stages, and here i just have a few options, just 6, grr, i have a business object that goes through 8 stages.

Best Answer

Use below code in xml file.


     <tree string = "Idea Junction" decoration-info="state=='open'" decoration-muted="state == 'rejected'" decoration-danger="state == 'close'" >

Avatar
Discard
Best Answer

Did you find out why everything is turning blue???

Avatar
Discard