コンテンツへスキップ
メニュー
この質問にフラグが付けられました
3 返信
67759 ビュー

how can I get the current date with the correct timezone of the user printing the report?

I am using this, but this brings the current UTC time.
<span t-esc="time.strftime('%Y-%m-%d %H:%M:%S')"/>

アバター
破棄
最善の回答
<span t-esc="context_timestamp(datetime.datetime.now()).strftime('%Y-%m-%d %H:%M')"/>   
アバター
破棄

This should be the correct answer

This is the correct answer

context_timestamp().strftime('%Y-%m-%d %H:%M') gives 'NoneType' object is not callable
error in odoo 14 with dt.dt.now() or with a datetime field or without parameter :(

Thanks a lot brother, this is the best answer

最善の回答

I have just created a module which allows you do to:

<span t-usertime="%Y-%m-%d %H-%M-%S" /> 

and get the correct timezone. See it on GitHub 

アバター
破棄

This has now been accepted in the OCA addons. Updated the github link.

最善の回答

Hi Vince,

    Can we add current datetime into Studio report also?

Thanks

アバター
破棄
関連投稿 返信 ビュー 活動
1
7月 25
1858
1
5月 25
1944
1
4月 25
2377
1
2月 25
1671
0
10月 24
1443