Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenERP strange date time issue

Tags:

openerp

I am using OpenERP version 6.1 and OpenERP web client. The OpenERP server is installed in my laptop hence both server and the client on the same machine.

The issue I am facing is that it looks like OpenERP treats my local time as current UTC time. My time zone in Windows is set to UTC+5:30 hours (Asia/Colombo) and the current time is 11:00 AM. When I see the current time from OpenERP using,

  'date_created': lambda *a: datetime.now().strftime('%Y-%m-%d %H:%M:%S'),

It shows me 03/29/2012 16:30:24 instead of correct time 11:00 AM. My observation is that OpenERP get the current time and add 5 hours 30 minutes to current time and shows me. So, OpenERP assumes my current local time as the current UTC time.

I must install the software at clients site but without this fixed, I cannot install.

like image 378
user1299906 Avatar asked Mar 29 '12 05:03

user1299906


2 Answers

The OpenERP v6.1 Release Notes state that now the server and database work exclusively with UTC dates, ignoring the OS timezone settings.

The timezone conversion is made dynamically by the client:

  • the Web client uses the browser setting (which usually matches the client machine settings)
  • the GTK client uses the setting in the user preferences.
like image 104
Daniel Reis Avatar answered Nov 07 '22 15:11

Daniel Reis


There is one golden rule for datetime fields in 6.1 addons code: "ALWAYS work in UTC - compute in UTC - save in UTC" The UTC values will be properly converted to local time when the result is diplayed in a client-side form.

like image 24
OmaL Avatar answered Nov 07 '22 14:11

OmaL