Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
3 Odpowiedzi
67449 Widoki

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

Awatar
Odrzuć
Najlepsza odpowiedź
<span t-esc="context_timestamp(datetime.datetime.now()).strftime('%Y-%m-%d %H:%M')"/>   
Awatar
Odrzuć

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

Najlepsza odpowiedź

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 

Awatar
Odrzuć

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

Najlepsza odpowiedź

Hi Vince,

    Can we add current datetime into Studio report also?

Thanks

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
lip 25
1606
1
maj 25
1567
1
kwi 25
2206
1
lut 25
1491
0
paź 24
1256