[FIX] hr_holidays: set fallback timezone when user has none

Field tz is not mandatory on res.partners, so we need a fallback in case
it is not defined.

Related to Issue : 1856843
Closes #25206
This commit is contained in:
Priyanka Kakadiya
2018-06-14 16:12:53 +02:00
committed by RomainLibert
parent 8d6ee5cb08
commit a4290faebf
+3 -2
View File
@@ -196,8 +196,9 @@ class HolidaysRequest(models.Model):
date_from = fields.Datetime.from_string(date_from)
date_to = fields.Datetime.from_string(date_to)
else:
date_from = timezone(self.env.user.tz).localize(datetime.combine(first_day, hour_from)).astimezone(UTC)
date_to = timezone(self.env.user.tz).localize(datetime.combine(last_day, hour_to)).astimezone(UTC)
tz = self.env.user.tz or 'UTC'
date_from = timezone(tz).localize(datetime.combine(first_day, hour_from)).astimezone(UTC)
date_to = timezone(tz).localize(datetime.combine(last_day, hour_to)).astimezone(UTC)
self.date_from = date_from
self.date_to = date_to