Skip to content

Commit

Permalink
[FIX] resource: update default calendar timezone on first admin login…
Browse files Browse the repository at this point in the history
… (follow-up)

Steps to reproduce:
-------------------
1. Install the resource module without demo data (or install any module which depends on it, again without demo data).
2. Login with the administrator user for the first time.
3. The default resource calendar (e.g. "Standard 40 hours/week") timezone will be set to 'UTC' by default
while it should be set to the timezone of the administrator.

Fix:
-------------------
When there is no demo data, no resource_calendar_id is linked to the admin.
In this case, we need to retrieve the record of the default working calendar and
set its timezone to the one of the admin user on the first login.

This is a follow-up of this fix: odoo#84258

task-3793313

X-original-commit: b280a9b
  • Loading branch information
deneuvillem committed Apr 19, 2024
1 parent a773c1d commit 3b041e8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion addons/resource/models/res_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ def write(self, vals):
# If the timezone of the admin user gets set on their first login, also update the timezone of the default working calendar
if (vals.get('tz') and len(self) == 1 and not self.env.user.login_date
and self.env.user == self.env.ref('base.user_admin', False) and self == self.env.user):
self.resource_calendar_id.tz = vals['tz']
if self.resource_calendar_id:
self.resource_calendar_id.tz = vals['tz']
else:
self.env.ref('resource.resource_calendar_std', False).tz = vals['tz']

return rslt

0 comments on commit 3b041e8

Please sign in to comment.