İçereği Atla
Odoo Menü
  • Portal
  • Ücretsiz deneyin
  • Uygulamalar
    Finans
    • Muhasebe
    • Faturalama
    • Masraf Yönetimi
    • Elektronik Çizelge (BI)
    • Belgeler
    • İmza
    Satış
    • Müşteri İlişkileri Yönetimi (CRM)
    • Satış
    • Satış Noktası Mağaza
    • Satış Noktası Restoran
    • Abonelikler
    • Kiralama
    Web Sitesi
    • Web Sitesi Oluşturucu
    • eTicaret
    • Blog
    • Forum
    • Canlı Sohbet
    • eÖğrenme
    Tedarik Zinciri
    • Envanter
    • Üretim
    • Ürün Yaşam Döngüsü Yönetimi
    • Satın Alma
    • Bakım
    • Kalite
    İnsan Kaynakları
    • Çalışanlar
    • İşe Alım
    • İzin
    • Değerlendirme
    • Referans
    • Filo Yönetimi
    Pazarlama
    • Sosyal Medyada Pazarlama
    • E-posta ile Pazarlama
    • SMS ile Pazarlama
    • Etkinlikler
    • Pazarlama Otomasyonu
    • Anket
    Hizmetler
    • Proje Yönetimi
    • Çalışma Çizelgeleri
    • Saha Hizmeti
    • Yardım Masası
    • Planlama
    • Randevular
    Verimlilik
    • Sohbet
    • Onay
    • Nesnelerin İnterneti
    • VoIP
    • Bilgi Bankası
    • WhatsApp
    Üçüncü taraf uygulamalar Odoo Stüdyo Odoo Bulut Platformu
  • Sektörler
    Perakende satış
    • Kitapçı
    • Giyim Mağazası
    • Mobilya Mağazası
    • Gıda Marketi
    • Hırdavat Dükkanı
    • Oyuncak Dükkanı
    Gıda ve Konaklama
    • Bar ve Pub
    • Restoran
    • Fast Food Restoranı
    • Konuk Evi
    • İçecek Distribütörü
    • Otel
    Gayrimenkul
    • Emlak Acentesi
    • Mimarlık Firması
    • İnşaat
    • Emlak Yönetimi
    • Bahçe Tasarımı
    • Mülk Sahipleri Derneği
    Uzmanlık
    • Muhasebe Firması
    • Odoo Partner
    • Pazarlama Ajansı
    • Hukuk Firması
    • Yetenek Kazanımı
    • Denetim ve Belgelendirme
    Üretim
    • Tekstil
    • Metal
    • Mobilyalar
    • Gıda
    • Bira fabrikası
    • Kurumsal Hediye
    Sağlık ve Spor
    • Spor Kulübü
    • Optik Mağazası
    • Fitness Merkezi
    • Sağlıklı Yaşam Merkezi
    • Eczane
    • Kuaför Salonu
    Ticaret
    • Tamirci
    • BT Donanım & Destek
    • Güneş Enerjisi Sistemleri
    • Ayakkabı İmalatçısı
    • Temizlik Hizmetleri
    • HVAC Hizmetleri
    Diğerleri
    • Kar Amacı Gütmeyen Kuruluş
    • Çevre Ajansı
    • Reklam Panosu Kiralama
    • Fotoğrafçılık
    • Bisiklet Kiralama
    • Yazılım Bayisi
    Tüm Sektörlere Göz Atın
  • Topluluk
    Öğrenim
    • Eğitim Araçları
    • Dokümantasyon
    • Sertifikasyonlar
    • Eğitim Etkinlikleri
    • Blog
    • Podcast
    Eğitim ve Gelişim
    • Eğitim Programı
    • Scale Up! İşletme Oyunu
    • Odoo'yu Ziyaret Edin
    Yazılım
    • İndirin
    • Sürümleri Kıyaslayın
    • Sürümler
    İş Birliği
    • Github
    • Forum
    • Etkinlikler
    • Çeviriler
    • Partner Olun
    • Partnerler için Hizmetler
    • Muhasebe Firmanızı Kaydettirin
    Hizmetler
    • Partner Bulun
    • Muhasebeci Bulun
    • Bir danışmanla görüşün
    • Kurulum Hizmetleri
    • Müşteri Referansları
    • Destek
    • Sürüm Yükseltme
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Demo randevusu alın
  • Fiyatlandırma
  • Yardım

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

  • Müşteri İlişkileri Yönetimi
  • e-Commerce
  • Muhasebe
  • Envanter
  • PoS
  • Proje Yönetimi
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
Yardım

Time & Date Issue

Abone Ol

Get notified when there's activity on this post

Bu soru işaretlendi
timezonedatetime
6 Cevaplar
12437 Görünümler
Avatar
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
Avatar
Vazgeç
Avatar
Asad Asif
Üretici En İyi Yanıt

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
Avatar
Vazgeç
Hilar Andikkadavath

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

Hilar Andikkadavath

Check My updated answer.

Avatar
Hilar Andikkadavath
En İyi Yanıt


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
Avatar
Vazgeç
Asad Asif
Üretici

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,

}

Avatar
Paresh Wagh
En İyi Yanıt

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
Avatar
Vazgeç
Enjoying the discussion? Don't just read, join in!

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

Üye Ol
İlgili Gönderiler Cevaplar Görünümler Aktivite
Take Users Timezone Çözüldü
timezone datetime
Avatar
Avatar
Avatar
Avatar
3
Tem 25
5185
How to add time difference on datetime object in Email Template ?
timezone datetime
Avatar
Avatar
Avatar
2
Mar 16
8643
How can I ignore timezone for a datetime field ?
timezone datetime
Avatar
0
Mar 15
9072
Datetime and Time Zones - OpenERP 7 Çözüldü
timezone datetime
Avatar
Avatar
1
Oca 24
13360
How do I print the current time (in the user's timezone) in a message I generate from an Automated Action
timezone user datetime
Avatar
Avatar
Avatar
Avatar
Avatar
4
Mar 23
16094
Topluluk
  • Eğitim Araçları
  • Dokümantasyon
  • Forum
Açık Kaynak
  • İndirin
  • Github
  • Runbot
  • Çeviriler
Hizmetler
  • Odoo.sh Hosting
  • Destek
  • Sürüm Yükseltme
  • Özel Geliştirmeler
  • Eğitim
  • Muhasebeci Bulun
  • Partner Bulun
  • Partner Olun
Hakkında
  • Şirketimiz
  • Pazarlama Gereçleri
  • İletişim
  • Kariyer
  • Etkinlikler
  • Podcast
  • Blog
  • Müşteriler
  • Hukuki • Gizlilik
  • Güvenlik
الْعَرَبيّة 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, müşteri ilişkileri yönetimi, eTicaret, muhasebe, envanter, satış noktası, proje yönetimi gibi şirketinizin tüm ihtiyaçlarını karşılayan bir açık kaynak işletme uygulamaları paketidir.

Odoo’nun eşsiz değer önermesi, aynı anda hem kullanımının çok kolay olup hem de tamamen entegre olmasıdır.

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