Odoo Help


Filter Invoices that are due within the next 7 days

Robert Klüsener
on 9/9/13, 7:23 AM 1,467 views

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

Torsten Francke
On 9/9/13, 9:16 AM

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.

Feuerwear GmbH & Co. KG, Robert Klüsener
on 9/9/13, 10:22 AM
  • relativedelta(days=7) is correct, sorry
initOS GmbH, Torsten Francke
on 9/9/13, 10:36 AM

Thanks! I modified it a bit and this works:

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

Feuerwear GmbH & Co. KG, Robert Klüsener
on 9/9/13, 10:50 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 9/9/13, 7:23 AM
Seen: 1467 times
Last updated: 1/18/17, 4:51 AM