Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
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())]
I tried a simple
[['date', '>=', context_today()]]
and it dint worked either...
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')))]
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', '>', current_date)]" ...../>
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.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 9/18/14, 5:56 AM|
|Seen: 1601 times|
|Last updated: 3/16/15, 8:10 AM|