Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

How to export date time as per my timezone in odoo 11?

Naroči se

Get notified when there's activity on this post

This question has been flagged
employeeattendance
2 Odgovori
8568 Prikazi
Avatar
Debasish

I tried to export datetime field of Attendance but i am getting wrong date time value. It is giving UTC date time instead my my timezone datetime.

How can i resolve this issue?  Please help me.

0
Avatar
Opusti
Waleed Ali Mohsen

There is no way to export the date in your timezone. You can change it in excel.

Avatar
Debasish
Avtor Best Answer

I just update in main.py file of controller of Web module. You can do this in inherit the main.py file.

Import below package in main.py

from dateutil.parser import parse
import datetime
import pytz

-->Update in CSVExport class for CSV. Add below code in this class.

def check_date(self, value):
        try:
            parse_data = parse(value)
            return parse_data
        except Exception as e:
            return False

Update from_data() function like below code.

def from_data(self, fields, rows):
        fp = io.BytesIO()
        writer = pycompat.csv_writer(fp, quoting=1)
        writer.writerow(fields)
        for data in rows:
                row = []
                for d in data:
                        if isinstance(d, pycompat.string_types) and d.startswith(('=', '-', '+')):
                                d = "'" + d
                        if type(d) is str:
                                parse_data = self.check_date(d)
                                if parse_data:
                                        if len(d) > 10:
                                                tz = pytz.timezone(request._context.get('tz'))
                                                d = (pytz.utc.localize(datetime.datetime.strptime(d,'%Y-%m-%d %H:%M:%S')).astimezone(tz)).strftime('%Y-%m-%d %H:%M:%S')

                        row.append(pycompat.to_text(d))
                writer.writerow(row)
        return fp.getvalue()

-->For Excel Update below code in ExcelExportV class in datetime condition.

elif isinstance(cell_value, datetime.datetime):
        tz = pytz.timezone(request._context.get('tz'))
        cell_value = (pytz.utc.localize(cell_value).astimezone(tz)).strftime('%Y-%m-%d %H:%M:%S')
        cell_style = datetime_style

After that, restart your odoo service and check.

2
Avatar
Opusti
Rodrigo Robles

Hello, nice feedback, I will try for my reports; btw, I'm having a problem with UTC-0; some date fields are not getting our correct tz for interpretation in Odoo, like: a ticket in UI shows create_day as 31/07/2019 22:00:00 (UTC -4), but from server (i think its server), it's set at 01/08/2019 02:00:00 (UTC-0), in display while we group it for month it will be shown in August instead of July, that is making trouble for us in all ways, and we don't know if changing the server timezone (have tried but failed) would affect Odoo usage for 1 company or multicompany. You know a way to solve this?

Sorry for commenting on another issue, and forgive me for my english, im not native.

Thanks beforehand.

Rodrigo

Avatar
Ray Carnes (ray)
Best Answer

All datetime information is exported in the UTC timezone, no matter your local timezone. This is so all Users anywhere in the world can collaborate. If your Business Support team in San Jose, California extracts data and sends it to the New York City office to be updated who then sends it to the London office, the only way this works is with a common underlying timezone. By using UTC we prevent any data corruption due to a User importing data while in a different timezone than the User who exported it. 

0
Avatar
Opusti
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Prijavi
Related Posts Odgovori Prikazi Aktivnost
Employee Attendance Resume Per Day
employee attendance
Avatar
0
nov. 24
1606
should OpenERP use calender view in Attendance??
employee attendance
Avatar
0
mar. 15
4251
Attendance: sign in and sign out [Error ! Sign in (resp. Sign out) must follow Sign out (resp. Sign in)]
employee attendance
Avatar
Avatar
1
sep. 25
7244
monitoring Employee Attendance with odoo cloud hosting (usb barcode) Solved
employee attendance barcode
Avatar
Avatar
Avatar
2
jul. 22
4309
[Odoo13] Generate QR Code for Badge Solved
employee attendance badge
Avatar
Avatar
3
feb. 20
7583
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now