コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
4385 ビュー

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

アバター
破棄
最善の回答

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')))]
アバター
破棄
著作者

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
著作者

Thanks! I modified it a bit and this works:

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

関連投稿 返信 ビュー 活動
0
1月 17
3122
0
7月 25
884
1
7月 25
648
2
7月 25
765
1
7月 25
1830