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

If  01.01.2016 23:59 is stored in the fields.Datetime() while a record is created (do not check 'write' method) the result in the DB is '01.01.2016 23:59'. But in the view I see '02.02.2016 01:59'. Two hours is added because of TZ as I think.

Does Odoo or Postgres modify the date? And how to get exactly the value I have sored?

Avatar
Vazgeç
En İyi Yanıt

Hi Artem,

Every date that you store in Odoo is shown to the user in his timezone (as set under the user his preferences).
In the back-end however all dates are converted to UTC and will be stored in the database in UTC. This means that every time that you see in the front-end is adjusted to the logged in his timezone while it is written away in UTC.
The reason this is done is to be consistent through-out Odoo and to have a rule that you can always fall back on to calculate dates and timezones.
You can simply get the stored value by printing it out for example:

my_date = self.your_date_field

Regards,
Yenthe

Avatar
Vazgeç
Üretici

I think it is useful to add an attribute like 'notzconversion'

You could get the current user his timezone and compensate it to write it away, I guess. I don't see a reason in doing so but it can be done.

Depending on the Odoo version, the timezone under the user preferences is ignored and Odoo will use system time instead. The user timezone is essentially useless then. See https://www.odoo.com/forum/help-1/question/what-is-the-purpose-of-the-user-timezone-if-all-dates-displayed-in-odoo-are-based-on-system-time-106845

İlgili Gönderiler Cevaplar Görünümler Aktivite
3
Haz 25
768
1
Tem 23
3477
4
Ara 22
9450
2
Nis 21
3531
1
Eki 18
4886