İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
67 Görünümler

I created an email template that I am sending to people who register for events via a custom module I am writing to manage pharmaceutical testing.

Everything works, but the timezone of the appointment is wrong.

How can I control which timezone is used to show the recipient the appointment time?

Avatar
Vazgeç
En İyi Yanıt

Odoo will convert the date/time value to the timezone set on the receipient contact (res.partner) record.

By default, this is the same timezone as the User creating it (or their browser timezone if that is not set, or UTC if we can't detect this from your browser).  If you creating Contacts via code, you can pass a value for the tz field so you can control which one is used.


You can see that in some of our own Email Templates, we assign this value by getting it from the record related to the email template or from context:

<t t-set="mail_tz" t-value="object._get_mail_tz() or ctx.get('mail_tz')"></t>

Then we use it to convert the UTC time of the event:

<t t-out="format_time(time=object.start, tz=mail_tz, time_format='short', lang_code=object.env.lang)">11:00 AM</t>

In this way all event or appointment or meeting times are shown in the local timezone of the receipient.


If you need to change the way this works, you can use a specific timezone based on the standard database of timezones - https://en.wikipedia.org/wiki/List_of_tz_database_time_zones

Avatar
Vazgeç