Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
3 Vastaukset
68250 Näkymät

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

Avatar
Hylkää
Paras vastaus
<span t-esc="context_timestamp(datetime.datetime.now()).strftime('%Y-%m-%d %H:%M')"/>   
Avatar
Hylkää

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

Paras vastaus

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 

Avatar
Hylkää

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

Paras vastaus

Hi Vince,

    Can we add current datetime into Studio report also?

Thanks

Avatar
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
1
heinäk. 25
2447
1
toukok. 25
2900
1
huhtik. 25
2885
1
helmik. 25
2150
0
lokak. 24
1837