Odoo Help


Set time to user's timezone in openerp 7?

Nick Athanasoulas
on 12/10/13, 6:06 PM 4,278 views

Hi there! I am trying to print a custom invoice. The problem is that I cannot print the user's local time. All I can is to print the in UTC Time Format. I am using the code below, but it doesn't work for displaying the time. My timezone is Europe/Athens.

I am making changes in the company's header.

Code:" <drawstring x="1cm" y="21.5cm"> [[ formatLang(time.strftime("%Y-%m-%d"), date=True) ]], Time: [[ time.strftime("%H:%M") ]]</drawstring>"

What I get: "12/10/2013, Time: 22:05" (My local time is 00:05 GMT+2)

Does anyone know how to make it work?

Nick Athanasoulas
On 12/11/13, 3:57 AM

Didnt's help. Should I change something?

I just edit it like that in the companies header form. "<para style="terp_default_8">[[ setLang(o.partner_id.lang) ]]</para>

<drawstring x="1cm" y="21.5cm"> [[ formatLang(time.strftime("%Y-%m-%d"), date=True) ]], Time: [[ time.strftime("%H:%M") ]]</drawstring>"

Still nothing. Printed GMT0 time not my local one.

I also found the addon called "invoice_date_time" and extract it to /usr/share/pyshared/openerp/addons/invoice_date_time but i dont know if its right. It doesn't print the time still. It prints GMT0 time, not GMT+2. My user has timezone:Europe Athens and lang to Greek.

How can I easily make it save in the users local time? Doesn't openerp do that by default? Maybe I have forgotten to check something in settings???

the add on link: https://www.openerp.com/apps/7.0/invoice_date_time


Omal Bastin

--Omal Bastin--

| 6 6 8
Kochi, Kerala, India
--Omal Bastin--

Swiming deep into openERP/ODOO

Omal Bastin
On 12/11/13, 12:57 AM

I think you need to first set the language.

 <para style="terp_default_8">[[ setLang(o.partner_id.lang) ]]</para>
Pierre verkest
On 11/28/14, 5:12 PM

I'm not sure if it's possible to use rml parser method in the header, I guess yes, it's what I did using webkit_report, I can use my parser methode in the webkit report header, which is mako format:


In the parser method you can define a methode like this to return the date time you needs:

from openerp.report import report_sxw
from tools.translate import _
from datetime import datetime
from openerp.tools import misc
from osv import osv
import pytz


        self.localcontext.update({'test_methode': self._test_methode,
                                  'displayDateTime': self._displayDateTime,


    def _displayDateTime(self, timezone, format='%d/%m/%Y %H:%M'):
            return pytz.timezone(
            raise osv.except_osv(_('Timezone error or date format invalid!'),
                                 _('Please set your timezone before to generate this report.') +
                                 _(' One of those values is not valid: timezone= %r - format= %r')
                                 % (timezone, format))

A bit late! hope it helps!

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 12/10/13, 6:06 PM
Seen: 4278 times
Last updated: 3/16/15, 8:10 AM