Odoo Help


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.


Today on a search filter

on 9/18/14, 5:56 AM 973 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

--Med Said BARA--
| 5 5 7
--Med Said BARA--
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')))]



| 5 4 7
Bangalore, India

Techno-Functional Associate with 6+ years of experience in Odoo (formerly known as OpenERP).

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

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

2 follower(s)


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