Odoo Help

1

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

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

Hi,


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??

2

Jignesh Mehta

--Jignesh Mehta--
2418
| 6 5 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.
Thanks,

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

Question tools

1 follower(s)

Stats

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