Bỏ qua để đến Nội dung
Odoo Menu
  • Đăng nhập
  • Dùng thử miễn phí
  • Ứng dụng
    Tài chính
    • Kế toán
    • Hóa đơn
    • Chi phí
    • Bảng tính (BI)
    • Tài liệu
    • Ký tên
    Bán hàng
    • CRM
    • Bán hàng
    • POS Cửa hàng
    • POS Nhà hàng
    • Đăng ký
    • Cho thuê
    Trang web
    • Trình tạo trang web
    • Thương mại điện tử
    • Blog
    • Diễn đàn
    • Trò chuyện trực tiếp
    • Học trực tuyến
    Chuỗi cung ứng
    • Tồn kho
    • Sản xuất
    • PLM
    • Mua hàng
    • Bảo dưỡng
    • Chất lượng
    Nhân sự
    • Nhân viên
    • Tuyển dụng
    • Ngày nghỉ
    • Đánh giá
    • Giới thiệu
    • Đội xe
    Marketing
    • Marketing trên MXH
    • Marketing qua email
    • Marketing qua SMS
    • Sự kiện
    • Tự động hóa Marketing
    • Khảo sát
    Dịch vụ
    • Dự án
    • Bảng chấm công
    • Dịch vụ hiện trường
    • Hỗ trợ
    • Kế hoạch
    • Lịch hẹn
    Năng suất
    • Thảo luận
    • Phê duyệt
    • IoT
    • VoIP
    • Kiến thức
    • WhatsApp
    Ứng dụng của bên thứ ba Studio Odoo Nền tảng Đám mây Odoo
  • Ngành
    Bán lẻ
    • Nhà sách
    • Cửa hàng quần áo
    • Cửa hàng nội thất
    • Cửa hàng tạp hóa
    • Cửa hàng đồ kim khí
    • Cửa hàng đồ chơi
    Ẩm thực & Dịch vụ lưu trú
    • Bar và quán rượu
    • Nhà hàng
    • Đồ ăn nhanh
    • Guest house
    • Nhà phân phối đồ uống
    • Khách sạn
    Bất động sản
    • Công ty môi giới bất động sản
    • Công ty kiến trúc
    • Xây dựng
    • Quản lý bất động sản
    • Làm vườn
    • Hiệp hội chủ sở hữu bất động sản
    Tư vấn
    • Công ty kế toán
    • Đối tác Odoo
    • Công ty marketing
    • Công ty luật
    • Tuyển dụng
    • Thanh tra & chứng nhận
    Sản xuất
    • Dệt may
    • Kim loại
    • Nội thất
    • Ẩm thực
    • Nhà máy bia
    • Quà tặng doanh nghiệp
    Sức khoẻ & fitness
    • CLB thể thao
    • Cửa hàng kính mắt
    • Trung tâm fitness
    • Chuyên gia chăm sóc sức khỏe
    • Hiệu thuốc
    • Tiệm làm tóc
    Thương mại
    • Dịch vụ sửa chữa
    • Phần cứng CNTT & Hỗ trợ
    • Hệ thống năng lượng mặt trời
    • Công ty sản xuất giày
    • Dịch vụ vệ sinh
    • Dịch vụ HVAC
    Khác
    • Tổ chức phi lợi nhuận
    • Cơ quan môi trường
    • Cho thuê biển quảng cáo
    • Nhiếp ảnh
    • Cho thuê xe đạp
    • Đại lý phần mềm
    Xem tất cả ngành
  • Cộng đồng
    Học tập
    • Khóa học
    • Tài liệu
    • Chứng chỉ
    • Đào tạo
    • Blog
    • Podcast
    Thúc đẩy đào tạo
    • Chương trình đào tạo
    • Trò chơi kinh doanh Scale Up!
    • Tham quan Odoo
    Nhận phần mềm
    • Tải xuống
    • So sánh các phiên bản
    • Phiên bản
    Hợp tác
    • Github
    • Diễn đàn
    • Sự kiện
    • Dịch thuật
    • Trở thành đối tác
    • Dịch vụ dành cho Đối tác
    • Đăng ký công ty kế toán của bạn
    Nhận dịch vụ
    • Tìm đối tác
    • Tìm kế toán
    • Gặp chuyên gia hỗ trợ
    • Dịch vụ Triển khai
    • Khách hàng tham khảo
    • Hỗ trợ
    • Nâng cấp
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Nhận một buổi demo
  • Bảng giá
  • Trợ giúp

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

  • CRM
  • e-Commerce
  • Kế toán
  • Tồn kho
  • PoS
  • Dự án
  • MRP
All apps
Bạn cần phải đăng ký để tương tác với cộng đồng.
Tất cả bài viết Người Huy hiệu
Thẻ (Xem tất cả)
odoo accounting v14 pos v15
Về diễn đàn này
Bạn cần phải đăng ký để tương tác với cộng đồng.
Tất cả bài viết Người Huy hiệu
Thẻ (Xem tất cả)
odoo accounting v14 pos v15
Về diễn đàn này
Hỗ trợ

Time & Date Issue

Đăng ký nhận tin

Nhận thông báo khi có hoạt động trên bài viết này

Câu hỏi này đã bị gắn cờ
timezonedatetime
6 Trả lời
12447 Lượt xem
Ảnh đại diện
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
Ảnh đại diện
Huỷ bỏ
Ảnh đại diện
Asad Asif
Tác giả Câu trả lời hay nhấ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
Ảnh đại diện
Huỷ bỏ
Hilar Andikkadavath

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

Hilar Andikkadavath

Check My updated answer.

Ảnh đại diện
Hilar Andikkadavath
Câu trả lời hay nhấ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
Ảnh đại diện
Huỷ bỏ
Asad Asif
Tác giả

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,

}

Ảnh đại diện
Paresh Wagh
Câu trả lời hay nhấ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
Ảnh đại diện
Huỷ bỏ
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!

Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!

Đăng ký
Bài viết liên quan Trả lời Lượt xem Hoạt động
Take Users Timezone Đã xử lý
timezone datetime
Ảnh đại diện
Ảnh đại diện
Ảnh đại diện
Ảnh đại diện
3
thg 7 25
5214
How to add time difference on datetime object in Email Template ?
timezone datetime
Ảnh đại diện
Ảnh đại diện
Ảnh đại diện
2
thg 3 16
8648
How can I ignore timezone for a datetime field ?
timezone datetime
Ảnh đại diện
0
thg 3 15
9080
Datetime and Time Zones - OpenERP 7 Đã xử lý
timezone datetime
Ảnh đại diện
Ảnh đại diện
1
thg 1 24
13366
How do I print the current time (in the user's timezone) in a message I generate from an Automated Action
timezone user datetime
Ảnh đại diện
Ảnh đại diện
Ảnh đại diện
Ảnh đại diện
Ảnh đại diện
4
thg 3 23
16113
Cộng đồng
  • Khóa học
  • Tài liệu
  • Diễn đàn
Open source
  • Tải xuống
  • Github
  • Runbot
  • Dịch thuật
Dịch vụ
  • Lưu trữ Odoo.sh
  • Hỗ trợ
  • Nâng cấp
  • Phát triển tùy chỉnh
  • Đào tạo
  • Tìm kế toán
  • Tìm đối tác
  • Trở thành đối tác
Giới thiệu công ty
  • Công ty của chúng tôi
  • Tài sản thương hiệu
  • Liên hệ
  • Việc làm
  • Sự kiện
  • Podcast
  • Blog
  • Khách hàng
  • Pháp lý • Riêng tư
  • Bảo mật
الْعَرَبيّة 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 là bộ ứng dụng kinh doanh có open source đáp ứng tất cả các nhu cầu của công ty bạn: CRM, thương mại điện tử, kế toán, tồn kho, POS, quản lý dự án, v.v.

Định hướng giá trị riêng biệt của Odoo là tích hợp hoàn toàn và dễ dàng sử dụng.

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