[FIX] hr_holidays: fix traceback to add timezone

Currently, Traceback occurs when we do timezone filters in every one
report of time off because the timezone is non-stored compute field in
hr leave model.

So in this commit, get the timzone value based on compute field from
resource or timezone of the current company's calendar OR user's tz
and at last 'UTC'.

closes odoo/odoo#61910

Taskid: 2334866
X-original-commit: 05c373a99a6064f08fc9eb0662ab2ccdb1978cd7
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
ppr-odoo
2020-11-18 01:51:27 +00:00
committed by Yannick Tivisse
parent d5c1cec0b1
commit 1bda0da91b
@@ -38,14 +38,20 @@ class LeaveReportCalendar(models.Model):
hl.date_to AS stop_datetime,
hl.employee_id AS employee_id,
hl.state AS state,
em.company_id AS company_id
em.company_id AS company_id,
CASE
WHEN hl.holiday_type = 'employee' THEN rr.tz
ELSE %s
END AS tz
FROM hr_leave hl
LEFT JOIN hr_employee em
ON em.id = hl.employee_id
LEFT JOIN resource_resource rr
ON rr.id = em.resource_id
WHERE
hl.state IN ('confirm', 'validate', 'validate1')
ORDER BY id);
""")
""", [self.env.company.resource_calendar_id.tz or self.env.user.tz or 'UTC'])
def _read(self, fields):
res = super()._read(fields)