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
    • 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 Managament
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Producție
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and 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
  • 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 & Date Issue

Abonare

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

Această întrebare a fost marcată
timezonedatetime
6 Răspunsuri
12429 Vizualizări
Imagine profil
Asad Asif

Hello All,

I am having some issues with Date and Time when generating reports.

I fully understand that by default Odoo stores all information in its Database in UTC format where as when I see the form view it shows the correct time & date as per timezone of the user.
​

The timezone of my server is set PKT (GMT+5), and the same time is set in postgresql.conf.

Lets suppose its 12.01 AM 25 July and I make any purchase order at that moment; and if I generate any report to see all the purchase orders made on 25 July it will NOT show this record as in Odoo Database this transaction was stored in UTC which is 7.01 PM 24 July. So this transaction will appear in the report for 24 July but as per me it was made on 25 July.

This is one just example, this is something happening on almost everything.

Can any one be kind enough to help me fix this issue in my modules.

I am using a few custom modules on as well on Odoo CE V11 and I am really looking forward to your expert advise.

Please help me.

Thanks

1
Imagine profil
Abandonează
Imagine profil
Asad Asif
Autor Cel mai bun răspuns

Hello Hilar,

Thanks for your answer, I dont know somehow I cant reply to you so now I am editing my answer so you can see this.

Can you please guide where to add this or if you dont mind can I paste the code for report view and py files here so you can guide accordingly.

Thanks

1
Imagine profil
Abandonează
Hilar Andikkadavath

Replace your the value in my answer with the DateTime field.

Hilar Andikkadavath

Check My updated answer.

Imagine profil
Hilar Andikkadavath
Cel mai bun răspuns


Actually, the database stores the Datetime field according to the system timezone. In Odoo, views which will be automatically converted according to the user's timezone if it is set.

Your TZ is. GMT+5),. So your custom operations on Datetime field need the proper conversion of Timezone according to the user.

Odoo views and ORM methods are treated the TZ with moment.js and the pytz conversions. This is actually a good feature to manage different timezones in Odoo.

You can use astimezone on Datetime objects:


def astimezone(self, tz): # known case of datetime.datetime.astimezone
    """ tz -> convert to local time in new timezone tz """
    return datetime(1, 1, 1)

or 

fields.Datetime.context_timestamp(self, datetime.strptime(value, DEFAULT_SERVER_DATETIME_FORMAT))
Examples:
1. date = date.replace(tzinfo=pytz.timezone('UTC')).astimezone(timezone)
2.
import time
from datetime import datetime
from pytz import timezone
import pytz

tz = partner_id.tz or self.env._context.get('tz') # Find Timezone from user or partner or employee
att_tz = timezone(tz or 'utc') # If no tz then return in UTC
attendance_dt = datetime.strptime(date, DEFAULT_SERVER_DATETIME_FORMAT) #Input date
att_tz_dt = pytz.utc.localize(attendance_dt)
att_tz_dt = att_tz_dt.astimezone(att_tz) # converted value to tz







1
Imagine profil
Abandonează
Asad Asif
Autor

Hello,

Thanks

In terms of coding I am very novice.

If you dont mind, I am pasting the code lines from my module.

Can you please make the changes in that and guide me.

My timezone in GMT+5 so based on that please guide me.

Really appreciate your guidance.

Thanks in advance.

-------------------------------------

from odoo import models, fields, api

import itertools

from operator import itemgetter

import operator

class report_goods_receive_report(models.AbstractModel):

_name = 'report.dev_inter_transfer.goods_receive_report_template'

@api.multi

def get_product_ids(self,obj):

domain = []

if obj.category_id:

domain.append(('categ_id','=',obj.category_id.id))

if obj.product_ids:

domain.append(('id','in',obj.product_ids.ids))

product_ids = self.env['product.product'].search(domain)

if product_ids:

return product_ids.ids

return False

@api.multi

def get_picking_type_ids(self,obj):

if obj.warehouse_id:

picking_ids = self.env['stock.picking.type'].search([('warehouse_id','in',obj.warehouse_id.ids),('code','=','incoming')])

return picking_ids

return False

@api.multi

def get_lines(self,obj):

inter_transfer_pool = self.env['dev.inter.transfer']

product_ids = self.get_product_ids(obj)

if obj.from_date and obj.to_date:

transfer_ids = inter_transfer_pool.search([('dest_warehouse_id','in',obj.warehouse_id.ids),

('date','>=',obj.from_date),

('date','<=',obj.to_date),

('state','=','validate')])

lst =[]

for tra in transfer_ids:

for transfer in tra.line_ids:

if transfer.product_id.id in product_ids:

qty = transfer.uom_id._compute_quantity(transfer.receive_qty, transfer.product_id.uom_id)

lst.append({

'product':transfer.product_id.name or '',

'qty':qty,

'price':transfer.product_id.standard_price or 0.0,

'uom_id':transfer.product_id and transfer.product_id.uom_id and transfer.product_id.uom_id.name or '',

})

from_date = obj.from_date +' 00:00:00'

to_date = obj.to_date+' 23:59:59'

picking_type_ids = self.get_picking_type_ids(obj)

if picking_type_ids and product_ids:

line_ids = self.env['purchase.order.line'].search([('order_id.date_order','>=',from_date),

('order_id.date_order','<=',to_date),

('order_id.picking_type_id','in',picking_type_ids.ids),

('product_id','in',product_ids),

('state','in',['purchase','done'])])

for line in line_ids:

pro_qty = line.product_qty

if line.qty_received:

pro_qty = line.qty_received

qty = line.product_uom._compute_quantity(pro_qty, line.product_id.uom_po_id)

lst.append({

'product':line.product_id.name or '',

'qty':qty,

'price':line.product_id.standard_price or 0.0,

'uom_id':line.product_uom and line.product_uom.name or '',

})

if lst:

n_lines=sorted(lst,key=itemgetter('product'))

groups = itertools.groupby(n_lines, key=operator.itemgetter('product'))

lst = [{'product':k,'values':[x for x in v]} for k, v in groups]

return lst

@api.multi

def set_total(self,total1, total2):

return float(total1) + float(total2)

@api.multi

def get_report_values(self, docids, data=None):

docs = self.env['goods.receive.report'].browse(docids)

return {

'doc_ids': docs.ids,

'doc_model': 'goods.receive.report',

'docs': docs,

'get_lines':self.get_lines,

'set_total':self.set_total,

}

Imagine profil
Paresh Wagh
Cel mai bun răspuns

Hi Asad:

Odoo displays the timezone information based on a user's preferences. However, if all your users are located in the same timezone you can try this:

  • Activate developer mode

  • Go to Settings > Users & Companies

  • Set the filter to "Inactive Users"

  • One of the inactive users will be something called "odoobot". Update the "Timezone" in the "Preferences" tab of this user to your local timezone.

0
Imagine profil
Abandonează
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
Take Users Timezone Rezolvat
timezone datetime
Imagine profil
Imagine profil
Imagine profil
Imagine profil
3
iul. 25
5163
How to add time difference on datetime object in Email Template ?
timezone datetime
Imagine profil
Imagine profil
Imagine profil
2
mar. 16
8640
How can I ignore timezone for a datetime field ?
timezone datetime
Imagine profil
0
mar. 15
9063
Datetime and Time Zones - OpenERP 7 Rezolvat
timezone datetime
Imagine profil
Imagine profil
1
ian. 24
13355
How do I print the current time (in the user's timezone) in a message I generate from an Automated Action
timezone user datetime
Imagine profil
Imagine profil
Imagine profil
Imagine profil
Imagine profil
4
mar. 23
16075
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