当 odoo 13 中两个日期相差 15 天时更改树视图中的颜色
Changing the color in tree view when there is a difference of 15 days between two dates in odoo 13
我正在努力改变 odoo 13 中树视图的颜色,以便在两个日期之间相差 15 天时为树视图着色
当一个比另一个大时我有这个
tree decoration-danger=" (date1 > date2)"
但是当两个日期相差 15 天时我需要。
谢谢
DateTime
和 relativedelta
在评估上下文中不可用。
您可以查看 _setDecorationClasses 函数文档,了解如何呈现这些属性:
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.
您只能访问字段的值和一些特殊变量,例如 uid
、active_id
、
您应该保留一个布尔字段 diff_15
:如果 difference(date1, date2) > 15 则为 True,否则为 False,然后在您的 XML 中使用此字段以实现正确的 class decoration-danger="diff_15 == True"
希望对您有所帮助。
我正在努力改变 odoo 13 中树视图的颜色,以便在两个日期之间相差 15 天时为树视图着色 当一个比另一个大时我有这个
tree decoration-danger=" (date1 > date2)"
但是当两个日期相差 15 天时我需要。
谢谢
DateTime
和 relativedelta
在评估上下文中不可用。
您可以查看 _setDecorationClasses 函数文档,了解如何呈现这些属性:
Each line can be decorated according to a few simple rules. The arch
description of the list may have one of thedecoration-X
attributes with
a domain as value. Then, for each record, we check if the domain matches
the record, and add thetext-X
CSS class to the element. This method is
concerned with the computation of the list of CSS classes for a given
record.
您只能访问字段的值和一些特殊变量,例如 uid
、active_id
、
您应该保留一个布尔字段 diff_15
:如果 difference(date1, date2) > 15 则为 True,否则为 False,然后在您的 XML 中使用此字段以实现正确的 class decoration-danger="diff_15 == True"
希望对您有所帮助。