Odoo Help

Welcome!

This community 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.

0

Filter Invoices that are due within the next 7 days

By
Robert Klüsener
on 9/9/13, 7:23 AM 961 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))]]

0
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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 9/9/13, 7:23 AM
Seen: 961 times
Last updated: 3/16/15, 8:10 AM