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

Let's use date_from field from hr.holidays.

How can you make a filter, to make it show only those records, which date_from field is in the same month as it is right now?

Basicly date_from.strftime('%Y-%m)==time.strftime('%Y-%m') is what I'm trying to accomplish. Tried domains:

domain="[(date_from.strftime('%Y-%m'),'=',time.strftime('%Y-%m'))]
domain="[('date_from'.strftime('%Y-%m'),'=',time.strftime('%Y-%m'))]

Neither worked. Also thought about making check in a range of dates e.g. time.strftime('%Y-%m-01')<=date_from<... and then I dont know how to find out whats the last date of a month nor get to add a month.

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

Hi Anti Nuga,

You can add current months record by adding domain like this,

domain="[('date_from','&gt;=',time.strftime('%%Y-%%m-01'))]"

Thanks

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

The dates can be bigger than this months... e.g. I don't want it show 2017-09-XX dates at the moment (Its 2017-08- right now)

Bài viết liên quan Trả lời Lượt xem Hoạt động
5
thg 9 20
12834
1
thg 3 15
5312
0
thg 3 15
3987
2
thg 3 15
7537
6
thg 5 24
71008