Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

Time Zone Discrepancy in Odoo Database Records

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
timezonepostgresqltimestampodoo16features
1 Răspunde
3810 Vizualizări
Imagine profil
gladiator

Hello,

My local time zone is 'Asia/Yangon,' but my Odoo database records datetime in UTC time. As a result, every time I generate a record directly from the database, it shows a 6.30-hour difference. Could you please guide me on how to convert the time zone of records generated directly from the database? Your assistance is greatly appreciated.

l.date_order -> This records which I want to change the Time Zone.


class PosReportGenerator(models.Model):
​_name = "pos.report"
​pos_report = fields.Char(string="PoS Report")
​date_from = fields.Datetime(string="Date From")
​date_to = fields.Datetime(string="Date to")
​report_type = fields.Selection([('report_by_order', 'Report By Order'),
​ ​ ​ ​ ​ ​ ​('report_by_order_detail', 'Report By Order Detail'),
​ ​ ​ ​ ​ ​ ​('report_by_product', 'Report By Product'),
​ ​ ​ ​ ​ ​ ​('report_by_categories', 'Report By Categories'),
​ ​ ​ ​ ​ ​ ​('report_by_salesman', 'Report By Salesman'),
​ ​ ​ ​ ​ ​ ​('report_by_payment', 'Report By Payment')],
​ ​ ​ ​ ​ ​ ​default='report_by_order')

def convert_time_zone(self,trans_date):
​tz = self.env.user.partner_id.tz and pytz.timezone(self.env.user.partner_id.tz) or pytz.utc
​localized_order_date = pytz.utc.localize(datetime.strptime(str(trans_date), "%Y-%m-%d %H:%M:%S")).astimezone(tz)
​return localized_order_date
def _get_report_sub_lines(self, data, report, date_from, date_to):
​report_sub_lines = []
​new_filter = None
​if data.get('report_type') == 'report_by_order':
​ ​query = '''select l.name,l.date_order,l.partner_id,l.amount_total,l.note,l.user_id,res_partner.name,l.name as shop,pos_session.name as session,
​ ​ ​ ​res_users.partner_id as user_partner,sum(pos_order_line.qty),l.id as id,
​ ​ ​ ​(SELECT res_partner.name as salesman FROM res_partner WHERE res_partner.id = res_users.partner_id)
​ ​ ​ ​from pos_order as l
​ ​ ​ ​left join pos_session on l.session_id = pos_session.id
​ ​ ​ ​left join res_partner on l.partner_id = res_partner.id
​ ​ ​ ​left join res_users on l.user_id = res_users.id
​ ​ ​ ​left join pos_order_line on l.id = pos_order_line.order_id'''
​ ​term = 'Where '
​ ​if data.get('date_from'):
​ ​ ​query += "Where l.date_order >= '%s' " % data.get('date_from')
​ ​ ​term = 'AND '
​ ​if data.get('date_to'):
​ ​ ​query += term + "l.date_order ​ ​query += "group by l.user_id,res_users.partner_id,res_partner.name,l.partner_id,l.date_order,pos_session.name,l.session_id,l.name,l.amount_total,l.note,l.id"
​ ​self._cr.execute(query)
​ ​report_by_order = self._cr.dictfetchall()
​ ​report_sub_lines.append(report_by_order)
0
Imagine profil
Abandonează
Imagine profil
Cybrosys Techno Solutions Pvt.Ltd
Cel mai bun răspuns

Hi,

To get current date time, you can follow the code below,
current_time = datetime.now()
user_tz = pytz.timezone(
request.env.context.get('tz') or request.env.user.tz)
date_today = pytz.utc.localize(current_time).astimezone(user_tz)
formatted_time = datetime.strftime(date_today, '%H:%M:%S')


Hope it helps

0
Imagine profil
Abandonează
gladiator
Autor

Thanks for sharing your information.
But I have retrieved the data directly from SQL. How can I convert l.date_order data time zone in that case.
Please guide me.

if data.get('date_from'):
query += "Where l.date_order >= '%s' " % data.get('date_from')
​ ​term = 'AND '

gladiator
Autor

Hi
I'm finally found the solution to change the Time Zone which is directly from the Database.

if data.get('date_from'):
query += "Where l.date_order AT TIME ZONE 'UTC' AT TIME ZONE 'Your Time Zone' >= '%s' " % data.get('date_from')
term = 'AND '

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

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

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
Postgres Issue
postgresql odoo16features
Imagine profil
Imagine profil
1
iun. 23
2798
Does Odoo works with Postgres 15?
postgresql odoo16features
Imagine profil
Imagine profil
1
mai 23
6979
CRONs aren't executed after a certain time
cron postgresql odoo16features
Imagine profil
Imagine profil
Imagine profil
3
apr. 24
4559
i want write a script that when i select table name the related column name of the table is show in the drop down in odoo Rezolvat
python postgresql odoo16features
Imagine profil
Imagine profil
1
mar. 23
3119
Export Time diifernet with live data
export timezone timestamp odoo10.0
Imagine profil
Imagine profil
3
aug. 19
5689
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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