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.

3

attendance timing is different when exporting the attendance

By
Davis
on 8/15/13, 1:41 AM 1,705 views

Hi, just like what I pointed on the title, whenever I export the files, it always shows UTC timezone instead of local timezone. For example, on attendance it shows Signed in at 8am and then signed out at 5pm but when i export the attendance it will become signed in at 1am and signed out at 10am in the exported csv . My timezone is GMT +7. Can anyone help me how to fix this problem? Thank you.

Have you found any solution for this one?

Laura Jarvenpaa
on 8/23/13, 2:01 AM

I have the same problem, does anyone found a solution? Otherwise, where is the script that manage the export?

Renaud
on 10/2/13, 5:09 AM

Is there any solution? I have the same Problem

Prakash
on 12/13/13, 3:09 AM
1

Prakash

--Prakash--
3173
| 5 4 7
Bikaner, India
--Prakash--

OpenERP Devloper at SunARC Technology

Prakash
On 12/16/13, 3:58 AM

1) Export_data method override 2) Using Python convert UTC time to User timezone or DB timezone

The below source Export method convert UTC time to DB time zone

def export_data(self, cr, uid, ids, fields, context=None):
        dataindex = None
        for index, fieldlabel in enumerate(fields):
            if fieldlabel == 'service_date':
                dataindex = index         
        res = super(model_name, self).export_data(cr, uid, ids, fields, context=context) 
        try:
            for index, val in enumerate(res['datas']):
                if dataindex:           
                    service_date = res['datas'][index][dataindex] 
                    sdate = service_date
                    if sdate:
                        sdate = str(sdate)
                    try:
                        cr.execute("SELECT current_setting('TIMEZONE')")
                        db_timezone = cr.fetchone()[0]
                    except:
                       db_timezone = "US/Eastern"
                       dbtz = pytz.timezone(db_timezone)
                       utctz = pytz.timezone('UTC')
                       sdate_dt = datetime.datetime.strptime(sdate, "%Y-%m-%d %H:%M:%S")
                       utctz_dt = utctz.localize(sdate_dt, is_dst=None)
                       db_dt = utctz_dt.astimezone(dbtz)                         
                       sdate = db_dt.strftime('%m/%d/%Y %H:%M:%S')
                       res['datas'][index][dataindex] = sdate
          except Exception, e:
               #print "Exception", e
                pass    
          return res

Thank's prakash

Suhas
on 4/28/16, 1:32 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

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

Question tools

1 follower(s)

Stats

Asked: 8/15/13, 1:41 AM
Seen: 1705 times
Last updated: 4/28/16, 1:31 AM