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

How to set my date default value as 05/08/2022??

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

You can do it as below:

my_date = fields.Date(string='My Date', default=lambda self: fields.Date.context_today(self).replace(day=8,month=5,year=2022))

Ảnh đại diện
Huỷ bỏ
Tác giả

It's working, where we can define the specific date format like DD/MM/YYYY

You can change it from Languages, Enable developer mode then Go to Settings -> Translations -> Languages -> open your language and edit the date format field to %d/%m/%Y

Tác giả

I tried the same but date showing 2022-05-08

You need to refresh the page. Which screen you check it?

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 6 25
1681
3
thg 7 25
3305
1
thg 5 25
1448
1
thg 5 25
1711
4
thg 5 25
2858