Odoo ERP Solution for displaying the local time in Reports/Documents

At times, when working with Odoo ERP Solution, we are faced with the issue of displaying local time on documents/reports. For instance, if the transaction is done at a particular time and stored in the database and we have a requirement to display that particular time by fetching it from database then instead of the expected transaction time (local time when the transaction took place) a different time is displayed. This happens because all records are stored using UTC 0 time instead of local time while recording any transactions.

For this issue what can be done is that we could add our local GMT time difference to the stored time value and receive the desired output. For Eg: Since we are at +5:30 GMT we would add the code as below:

import pytz
from datetime import datetime

_form_date = datetime.today()
time_zone=’Asia/Calcutta’
tz = pytz.timezone(time_zone)
tzoffset = tz.utcoffset(_from_date)
_from_date = _from_date + tzoffset

This way you could display the exact local time when the particular transaction occurred. Contact Nevpro.co.in today.

One response to “Odoo ERP Solution for displaying the local time in Reports/Documents”

  1. Sam says:

    I’m Using openerp from last one year… i was stuck with UTC time..thx for the posting these blog.

You must be logged in to post a comment.