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.

4

Timezone issue in OpenERP 7.0 version [Closed]

By
Ghanshyam Prajapati
on 6/6/13, 4:16 AM 8,673 views

The Question has been closed

by
Sudhir Arya (SA)
on 06/06/2013 05:29:53

Hi, I m working with OpenERP 7.0 Version, when I start OpenERP server it display current time on terminal.

2013-06-06 **05:33:32,972 2486** INFO my_module werkzeug: 127.0.0.1 - - [06/Jun/2013 05:33:32] "GET /web/binary/image?model=res.partner&field=image_small&id=37&session_id=2683239f22164b0eba5cb58b0049b1dc HTTP/1.1" 304 -
2013-06-06 05:33:32,974 2486 INFO my_module werkzeug: 127.0.0.1 - - [06/Jun/2013 05:33:32]

My actual system time is 2013-06-06 11:18:38 AM. I searched for my problem on Google and I found that OpenERP server takes default timezone GMT or login user's timezone.

I changed login user's timezone from Preferences 'Asia/Calcutta'(GMT +05:30), but still OpenERP server shows me GMT time.

Even when I use datetime.datetime.now().hour in my module, it gives wrong hour.

How can I solve this issue..?????

Please help me.

Thanks in advance.

7

Sudhir Arya (SA)

--Sudhir Arya (SA)--
10150
| 6 8 8
Ahmedabad, India
--Sudhir Arya (SA)--

Working as an OpenERP/Odoo developer and a Team Leader 

Top 5 Odoo contributor On Stackoverflow

LinkedIn

Blog

Stackoverflow

Sudhir Arya (SA)
On 6/6/13, 5:19 AM

Since OpenERP 6.1, the timezone of all Python operations happening on the server-side (and in modules) is forced to be UTC. This was a design decision explained in various places. The rendering of datetime values in the user's timezone is meant to be done on the client-side exclusively.

Reference: OpenERP Release Notes

If you want to convert time as per Users specific timezone then there is a method in OpenERP:

from openerp.osv import fields
from datetime import datetime
my_date = fields.datetime.context_timestamp(cr, uid, datetime.now(), context=context)
print "My Datetime: ", my_date
print "Hour: ", my_date.hour

Output:

My Datetime: 2013-06-06 12:28:22.249559+05:30
Hour: 12

Hope this will help you.

unfortunately the rendering to the users timezone does not work correctly everywhere. Attendances and timesheets are two examples (http://help.openerp.com/question/31908/how-to-get-attendance-be-assigned-to-the-correct-day-for-anyone-who-is-not-in-the-utc-timezone)

gunnar
on 10/7/13, 10:44 PM

Hello Sudhir Arya, the fact that OpenERP allways records date & time in UTC in the database is a big problem. Im implementing point of sale and when I print a report, the report is just incorrect because in the DB changes the values, how is it posible to use the method above to write the correct time zone in the DB? Thanks in advance!!

MEXYTUL, Diego Calzadilla
on 1/22/14, 1:32 PM

I solved that problem by changing some line in orm.py, OpenERP doesn't record in UTC in DB, I changed to do it in CST

MEXYTUL, Diego Calzadilla
on 1/30/14, 2:48 PM

Hi Diego can you please explain ,How you solve this issue? I am also facing this issue ,bcz I am working with POS Module .So kindly help........

Odoo
on 12/7/15, 10:48 AM

About This Community

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

Question tools

3 follower(s)

Stats

Asked: 6/6/13, 4:16 AM
Seen: 8673 times
Last updated: 3/16/15, 8:10 AM