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.


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

Sebin Siby
on 7/30/16, 3:30 AM 210 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--
| 6 4 8
Surat, India
--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.

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

1 follower(s)


Asked: 7/30/16, 3:30 AM
Seen: 210 times
Last updated: 9/6/16, 9:46 AM