İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
4386 Görünümler

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))]]

Avatar
Vazgeç
En İyi Yanı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')))]
Avatar
Vazgeç
Üretici

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
Üretici

Thanks! I modified it a bit and this works:

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

İlgili Gönderiler Cevaplar Görünümler Aktivite
0
Oca 17
3124
0
Tem 25
885
1
Tem 25
650
2
Tem 25
770
1
Tem 25
1834