تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
3 الردود
67534 أدوات العرض

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
يوليو 25
1661
1
مايو 25
1631
1
أبريل 25
2239
1
فبراير 25
1528
0
أكتوبر 24
1287