Odoo Help


Creating "This week" or "Today +7 days" filter [Closed]

on 6/11/13, 6:52 AM 9,350 views

The Question has been closed

Sudhir Arya (ERP Harbor Consulting Services)
on 06/11/2013 08:56:24

How can I create a filter for "This week" or a set of 7 days, starting with the current date? I want to add this filter under project.task.

I have tried to filter on date_start like this:


image description

But whenever I try to filter it sais: "Uncaught TypeError: Cannot read property 'length' of undefined".

What do I need to correct/change in my filter; or is there a better way to do this?

On 6/11/13, 8:52 AM
[('date_start','>=', ((context_today()).strftime('%Y-%m-%d'))), ('date_start','<=', ((context_today()+datetime.timedelta(days=7)).strftime('%Y-%m-%d')))]

The above will look for everything that is between today and 7 days from now. It also filters everything about before today. Switch "date_start" to another field to use this filter in another model.

what if i need to put the domain on the current week of the year not from today.?

Mostafa Abd El Fattah
on 9/20/16, 4:23 AM

Andreas Brueckl

--Andreas Brueckl--

| 7 8 7
Vienna, Austria
--Andreas Brueckl--
OpenERP Consulting and Development
Andreas Brueckl
On 6/11/13, 7:13 AM

Hey Andreas, thank you for your reference. I hadn't come across that post yet.

If I use: "[('date_start','<=', ((context_today()+datetime.timedelta(days=7)).strftime('%Y-%m-%d')))]" I can show all my task for today + 7 days, but also everything before.

If I take away the "<" from the definition; it just takes incredibly long to load the result and it doesn't stop loading.

Can I change the function to leave out everything before today, or should I add a second operator which filters on everything before today and link them with AND?

on 6/11/13, 8:09 AM

I need to combine: [('date_start','>=', ((context_today()).strftime('%Y-%m-%d')))] and [('date_start','<=', ((context_today()+datetime.timedelta(days=7)).strftime('%Y-%m-%d')))]. Now I just need to find the right way to use and AND-operator in this string. I'll try to find the correct way to do this. Thanks for your assistance.

on 6/11/13, 8:34 AM

Found it through trial and error.

on 6/11/13, 8:52 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: 6/11/13, 6:52 AM
Seen: 9350 times
Last updated: 3/16/15, 8:10 AM