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

How can I filter all invoices that are due within the next 7 days? I tried the following code and it does not work out:

[['date_due', '<=', time.strftime('%Y-%m-%d %H:%M:%S',time.gmtime(time.time()+7243600))]]

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

hi you should use context_today(), try somethink like:

['&',('date_due','<', ((context_today() + relativedelta(days=7)).strftime('%Y-%m-%d'))),('date_due','>', ((context_today()).strftime('%Y-%m-%d')))]
Ảnh đại diện
Huỷ bỏ
Tác giả

Unfortunately this does not work out.

['&',('date_due','<', ((context_today() + relativedelta(weeks=0,day=7, weekday=-1)).strftime('%Y-%m-%d'))),('date_due','>', ((context_today()).strftime('%Y-%m-%d')))]

Does show no invoice

[('date_due','<=', ((context_today() + relativedelta(weeks=0,day=7, weekday=-1)).strftime('%Y-%m-%d')))]

Does show only the invoices that are due before today but not the invoices which became due in the next 7 days.

  • relativedelta(days=7) is correct, sorry
Tác giả

Thanks! I modified it a bit and this works:

[('date_due','<=', ((context_today() + relativedelta(days=7)).strftime('%Y-%m-%d')))]

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 1 17
3134
1
thg 8 25
55
0
thg 7 25
890
1
thg 7 25
687
2
thg 7 25
787