odoo time zone problem

Since the UTC time zone is stored in the database, both data export and group by have time zone issues by default.
Complete solution: Change the data stored in the UTC time zone to be stored in the target time zone, and remove the time zone conversion in JS .

1. Modify the Odoo system environment time zone:
odoo/openerp/__init__.py file
import os
os.environ['TZ'] = 'UTC' # Change the UTC here to Asia/Shanghai or other target time zone

2. Modify the web page time zone Converted JS file:
Two methods in odoo/addons/web/static/src/js/openerpframework.js
openerp.str_to_datetime string to time
openerp.datetime_to_str Time to string
removes the UTC characters in these two methods.

3. Modify the SQL query or insert statement executed in UTC time:
remove all statements with the string "at time zone 'UTC'" or "at time zone 'utc'".
 odoo/openerp/models.py especially the field values ​​of create_date and write_date;
 odoo/openerp/addons/base/ir/ir_cron.py change the UTC time zone to the current time zone in the scheduled task;
 odoo/openerp/netsvc.py backup database name time stamp

4. Modify the statement with "at time zone" string in other functional modules to get UTC time.
 Such as calendar module and hr_timesheet_sheet module

 

 

2016-10-05 Added:

Odoo9.0 is not the same as 8.0. I can't find the time conversion place of js. I don't have time to debug it. On hold for now.

It feels like I have to change the server timezone to UTC. Then, which time zone is selected in the user preferences in ODOO is the time corresponding to which time zone.

But if you share a server with other applications, it is unlikely to change the server time zone to UTC.

If you want to change all the astimezone places in the code, it feels a bit tricky.

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327052055&siteId=291194637