Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
67468 Lượt xem

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất
<span t-esc="context_timestamp(datetime.datetime.now()).strftime('%Y-%m-%d %H:%M')"/>   
Ảnh đại diện
Huỷ bỏ

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

Câu trả lời hay nhất

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 

Ảnh đại diện
Huỷ bỏ

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

Câu trả lời hay nhất

Hi Vince,

    Can we add current datetime into Studio report also?

Thanks

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 7 25
1621
1
thg 5 25
1577
1
thg 4 25
2215
1
thg 2 25
1502
0
thg 10 24
1259