Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

[odoo 9.0] fields.Datetime is read with server TZ? Feature or bug?

By
Artem
on 10/11/16, 1:25 PM 117 views

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?

2

Yenthe

--Yenthe--
6716
| 7 7 8
Turnhout, Belgium
--Yenthe--

My Odoo blog: http://www.odoo.yenthevg.com/

My Twitter: https://twitter.com/Yenthe666

Yenthe
On 10/12/16, 1:53 AM

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

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

Artem
on 10/12/16, 7:07 AM

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.

Yenthe
on 10/12/16, 7:17 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 10/11/16, 1:25 PM
Seen: 117 times
Last updated: 10/12/16, 7:07 AM