Changing the color in tree view when there is a difference of 15 days between two dates in odoo 13

680 Views Asked by At

I am working on changing the color in tree view in odoo 13 for colorize tree view when there is a difference of 15 days between two dates for example I have this when one is bigger than the other

tree decoration-danger=" (date1 > date2)"

but i need when there is a difference of 15 days between two dates.

Thanks

2

There are 2 best solutions below

0
On BEST ANSWER

You should persist a boolean field diff_15: True if difference(date1, date2) > 15 and False otherwise, then use this field in your XML to achieve the proper class decoration-danger="diff_15 == True"

I hope this can be helpful for you.

0
On

DateTime and relativedelta are not available in the evaluation context.

You can check the _setDecorationClasses function documentation on how those attributes are rendered:

Each line can be decorated according to a few simple rules. The arch
description of the list may have one of the decoration-X attributes with
a domain as value. Then, for each record, we check if the domain matches
the record, and add the text-X CSS class to the element. This method is
concerned with the computation of the list of CSS classes for a given
record.

You have access only to the values of the fields and some special variables like uid, active_id,