[FIX] hr_attendance: Fix traceback on creation of employee

Currently, when you create a employee when hr_aattance is installed
then it will create traceback due to falder timiezone

so in this commit, Fix the issue and if timezone is not set on
employee then pass the 'UTC'

TaskID: 2283753
This commit is contained in:
Barad Mahendra
2020-08-21 06:07:59 +00:00
parent 9c745e0271
commit 2cb194e1b5
+1 -1
View File
@@ -42,7 +42,7 @@ class HrEmployeeBase(models.AbstractModel):
now = fields.Datetime.now()
now_utc = pytz.utc.localize(now)
for employee in self:
tz = pytz.timezone(employee.tz)
tz = pytz.timezone(employee.tz or 'UTC')
now_tz = now_utc.astimezone(tz)
start_tz = now_tz + relativedelta(months=-1, day=1, hour=0, minute=0, second=0, microsecond=0)
start_naive = start_tz.astimezone(pytz.utc).replace(tzinfo=None)