Skip to content

[18.0][ADD] web_timezone_auto - #3755

Open
klodr wants to merge 1 commit into
OCA:18.0from
klodr:18.0-add-web_timezone_auto
Open

klodr wants to merge 1 commit into
OCA:18.0from
klodr:18.0-add-web_timezone_auto

Conversation

@klodr

@klodr klodr commented Oct 26, 2026

Copy link
Copy Markdown

New module: web_timezone_auto

Keeps each user's time zone in line with the device they use.

Problem. Odoo only reads the browser time zone at login, from the tz cookie set by its own login page, and only when the user has no time zone yet (res.users._login). Users who log in through an external identity provider (OAuth/OIDC) skip that page, so their time zone stays empty and the Preferences show the mismatch warning; users who travel keep their old time zone. The server then computes e-mails, reports, activity deadlines and scheduled actions in the wrong time zone, while the web client shows the device time.

What the module does.

  • Adds Automatic Time Zone (tz_auto) on users, checked by default (existing users included), readable and writable by the user.
  • When the web client starts, if the setting is on and the device time zone (Intl.DateTimeFormat().resolvedOptions().timeZone) differs from the user's, the client asks the server to write it; the server decides (res.users.web_timezone_auto_sync): known pytz zone only, current user only, setting on, never for the superuser, never while impersonating (impersonate_login). It writes only when the zone actually changes (writing tz clears the server caches), updates the session context, and returns the zone so the page and other tabs use it.
  • The first page already uses the new time zone: the service returns its promise, bounded to 2 seconds so a silent server never blocks the interface; a late answer no longer changes the page.
  • Preferences and user form: the setting sits right before the time zone, which is read-only while it is checked.

Tests. Python (12) including two real HTTP sessions (session context updated at once; nothing written while impersonating), and Hoot (8) including the startup wait and a silent server. Each rule was removed in turn to check that its test fails.

Field use. Deployed on our instance (production and three client databases) since 2026-10-25.

Translations will go through Weblate.

Keep each user's time zone in line with the device they use.

Odoo only reads the browser time zone at login, from a cookie set by its own
login page, and only when the user has none. Users logging in through an
external identity provider never get one, and travelling never changes it, so
e-mails, reports, deadlines and scheduled actions use the wrong time zone.

Each time the interface opens, the device time zone is compared with the
user's one and, when they differ, written by the server (known pytz zone,
current user only, setting enabled, never while impersonating nor for the
superuser). The first page already uses it; the interface never waits more
than two seconds. Users can uncheck "Automatic Time Zone" in their
Preferences to keep a fixed one.

Signed-off-by: Claude Perrin <klodr@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:web_timezone_auto Module web_timezone_auto series:18.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants