Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
3 Răspunsuri
67685 Vizualizări

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')"/>

Imagine profil
Abandonează
Cel mai bun răspuns
<span t-esc="context_timestamp(datetime.datetime.now()).strftime('%Y-%m-%d %H:%M')"/>   
Imagine profil
Abandonează

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

Cel mai bun răspuns

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 

Imagine profil
Abandonează

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

Cel mai bun răspuns

Hi Vince,

    Can we add current datetime into Studio report also?

Thanks

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
1
iul. 25
1818
1
mai 25
1908
1
apr. 25
2363
1
feb. 25
1659
0
oct. 24
1433