Odoo Help


Today on a search filter

on 9/18/14, 5:56 AM 1,529 views

I want to create a user defined filter to filter events ocurring in the next 7 days 

used the folowing code

[('date','<=', ((context_today()-datetime.timedelta(days=7)).strftime('%Y-%m-%d')))],[('date','>=', context_today())]

Didnt worked

I tried a simple

[['date', '>=', context_today()]]

and it dint worked either...


Med Said BARA
On 9/18/14, 7:19 PM

For Events, there is no field date, you should use date_begin


[('date_begin','>=', ((context_today()).strftime('%Y-%m-%d'))), ('date_begin','<=', ((context_today()+datetime.timedelta(days=7)).strftime('%Y-%m-%d')))]

On 9/19/14, 4:39 AM

I  also had same requirement, for 3 days...

So I used functional field say next_7th_date, which will calculated the date (in your case 7th day from date) and saved it in db...

Then  used it in XML search view like this

<filter name="next_7th_date"  domain="[('next_7th_date', '&gt;', current_date)]" ...../>


This w

Using the filter bellow is simpler and more flexible!

on 9/19/14, 1:15 PM
On 9/19/14, 1:14 PM

somehow we have to refresh to reload the filter...

under the user defined filters the following code works!

['date', '>=', context_today().strftime('%Y-%m-%d')],
['date', '<', (context_today() + datetime.timedelta(7)).strftime('%Y-%m-%d')],

With the advantage of having all the data. Filters are a more convenient way than xml search

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

2 follower(s)


Asked: 9/18/14, 5:56 AM
Seen: 1529 times
Last updated: 3/16/15, 8:10 AM