Pointer
Pointer

Reputation: 2186

Change color for saturday and sunday date field in tree view odoo 9

Is it possible change color line for saturday and sunday date field in tree view?

Upvotes: 2

Views: 932

Answers (2)

tidylobster
tidylobster

Reputation: 723

You can define a color field in your model and assign it to red when it's Sunday or Saturday.

class YourClass(models.Model):

    @api.one
    def _get_color(self):
        #if it's saturday or sunday
             self.color = "red"

    color = fields.Char("Color", compute=_get_color)

Then, you have to modify a little your tree view.

<tree string="Your tree view" colors="red:color=='red'">
    <field name="color" invisible="True"/>
    ...
</tree>

After that, the row in a tree view would be printed as red.

Hope, that will help.

Upvotes: 1

CZoellner
CZoellner

Reputation: 14768

Seems to be not possible with the latest version of Odoo. You could use the new decorations for that, but the python expression context doesn't have datetime or any other date library loaded into it anymore (i think the old colors possibility allowed datetime use).

Maybe it will be possible with Odoo 11 again.

Upvotes: 2

Related Questions