Odoo Help


How could I write the condition in search to get records within a date range?

Sebin Siby
on 7/30/16, 3:30 AM 602 views


I have two date fields "from_date" and "to_date" and if the current date is between or equal to "from_date" or" to_date" I want to get all such records from the model.

How could I search these records??

--Jignesh Mehta--

Jignesh Mehta
On 7/30/16, 5:20 AM

Hello Sebin,

Try this :-

search_obj = self.env['model.name'].search([('from_date', '>=', fields.date.today()), ('to_date', '<=', fields.date.today())])

Hope it works for you.

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: 7/30/16, 3:30 AM
Seen: 602 times
Last updated: 9/6/16, 9:46 AM