コンテンツへスキップ
Odoo メニュー
  • サインイン
  • 無料で15日試す
  • アプリ
    財務
    • 会計
    • 請求
    • 経費
    • スプレッドシート(BI)
    • ドキュメント管理
    • 署名
    販売
    • CRM
    • 販売
    • POS店舗
    • POSレストラン
    • サブスクリプション
    • レンタル
    ウェブサイト
    • ウェブサイトビルダー
    • eコマース
    • ブログ
    • フォーラム
    • ライブチャット
    • eラーニング
    サプライチェーン
    • 在庫
    • 製造
    • 製品ライフサイクル管理 (PLM)
    • 購買
    • 整備
    • 品質
    人事業務
    • 従業員管理
    • 採用
    • 休暇管理
    • 人事評価
    • リファラル
    • フリート
    マーケティング
    • ソーシャルマーケティング
    • メールマーケティング
    • SMSマーケティング
    • イベント
    • マーケティングオートメーション
    • アンケート調査
    サービス
    • プロジェクト管理
    • タイムシート
    • フィールドサービス
    • ヘルプデスク
    • 計画
    • アポイントメント
    生産性向上ツール
    • ディスカッション
    • 承認
    • IoT
    • VoIP
    • ナレッジ
    • WhatsApp
    サードパーティアプリ Odooスタジオ Odooクラウドプラットホーム
  • インダストリー(業種別ソリューション)
    小売
    • 書店
    • アパレルショップ
    • 家具専門店
    • 食料品店
    • 金物店
    • 玩具店
    飲食・ホスピタリティ業界
    • バー・パブ
    • レストラン
    • ファストフード
    • ゲストハウス
    • 飲料販売代理店
    • ホテル
    不動産
    • 不動産会社
    • 建築事務所
    • 建設
    • 不動産管理
    • 造園
    • 住宅所有者組合
    コンサルティング
    • 会計事務所
    • Odooパートナー
    • マーケティングエージェンシー
    • 法律事務所
    • 人材派遣
    • 監査・認証
    製造
    • テキスタイル
    • 金属
    • 家具
    • 飲食
    • 醸造所
    • コーポレートギフト
    ヘルス & フィットネス
    • スポーツクラブ
    • 眼鏡店
    • フィットネスセンター
    • ウェルネス専門家
    • 薬局
    • ヘアサロン
    業種
    • 便利屋
    • IT ハードウェア・サポート
    • 太陽エネルギーシステム
    • 靴メーカー
    • クリーニングサービス
    • 空調設備サービス
    その他
    • 非営利団体
    • 環境機関
    • ビルボードレンタル
    • 写真
    • 自転車リース
    • ソフトウェアリセラー
    すべての業種を見る
  • コミュニティ
    学ぶ
    • チュートリアル
    • ドキュメンテーション
    • 認定
    • トレーニング
    • ブログ
    • ポッドキャスト
    教育サポート
    • 教育プログラム
    • Scale Up! ビジネスゲーム
    • Odooオフィス訪問
    ソフトを入手
    • ダウンロード
    • エディションを比較
    • リリース
    コラボレーション
    • Github
    • フォーラム
    • イベント
    • 翻訳
    • パートナーになる
    • パートナー様向けサービス
    • 会計事務所を登録
    サービス利用
    • パートナー一覧
    • 会計事務所一覧
    • 今すぐ相談する
    • 導入支援サービス
    • お客様一覧
    • サポート
    • アップグレード
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    製品デモを利用する
  • 料金
  • ヘルプ

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

  • CRM
  • e-Commerce
  • 会計
  • 在庫
  • PoS
  • プロジェクト
  • MRP
All apps
コミュニティで交流するには登録する必要があります。
全てのポスト 人々 バッジ
タグ (全て表示)
odoo accounting v14 pos v15
このフォーラムについて
コミュニティで交流するには登録する必要があります。
全てのポスト 人々 バッジ
タグ (全て表示)
odoo accounting v14 pos v15
このフォーラムについて
ヘルプ

Time Zone Discrepancy in Odoo Database Records

購読

この投稿に活動があった際に通知を受け取ります

この質問にフラグが付けられました
timezonepostgresqltimestampodoo16features
1 返信
3791 ビュー
アバター
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
アバター
破棄
アバター
Cybrosys Techno Solutions Pvt.Ltd
最善の回答

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
アバター
破棄
gladiator
著作者

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
著作者

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 '

ディスカッションを楽しんでいますか?読むだけでなく、参加しましょう!

今すぐアカウントを作成して、限定機能を利用したり、素晴らしいコミュニティと交流しましょう!

登録
関連投稿 返信 ビュー 活動
Postgres Issue
postgresql odoo16features
アバター
アバター
1
6月 23
2786
Does Odoo works with Postgres 15?
postgresql odoo16features
アバター
アバター
1
5月 23
6959
CRONs aren't executed after a certain time
cron postgresql odoo16features
アバター
アバター
アバター
3
4月 24
4548
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 解決済
python postgresql odoo16features
アバター
アバター
1
3月 23
3112
Export Time diifernet with live data
export timezone timestamp odoo10.0
アバター
アバター
3
8月 19
5687
コミュニティ
  • チュートリアル
  • ドキュメンテーション
  • フォーラム
オープンソース
  • ダウンロード
  • Github
  • Runbot
  • 翻訳
サービス
  • Odoo.shホスティング
  • サポート
  • アップグレード
  • カスタム開発
  • 教育プログラム
  • 会計事務所一覧
  • パートナー一覧
  • パートナーになる
企業情報
  • 会社概要
  • ブランドアセット
  • お問い合わせ
  • 採用情報
  • イベント
  • ポッドキャスト
  • ブログ
  • お客様一覧
  • リーガル情報 • プライバシーポリシー
  • セキュリティ
الْعَرَبيّة 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(オドゥー)は、CRM、eコマース、会計、在庫管理、POS、プロジェクト管理など、企業のさまざまな業務を一つのシステムで管理できる、ベルギー発のオープンソースのERPソフトウェアです。

高機能で使いやすく、完全に統合されたERPとして、ユニークな価値を提供しています。

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