Odoo Help


Date Comparision doesn't work fine in openerp7

on 9/26/13, 9:46 AM 1,292 views

Hi, I have 2 dates (from date and to date) in hand. I would like to know if there's another record in the table that falls on the same range. I use openerp search function to do that

below is my code. Kindly see if my date search with operator <= is correct and is there anything that i wrongly understood.

exist_ids = self.search(cr, uid, [('partner_id','=',customer),('sys_conf_name','ilike',sys_conf_name.strip()),('contract_start_date','<=',cont_start_date),('contract_end_date','>=',cont_end_date)])
if exist_ids:
      raise osv.except_osv(_('Error!!'), "Already there exist a Contract for the same customer, same product and the same date range!!")

Thanks for your time.


Andreas Brueckl

--Andreas Brueckl--

| 7 8 7
Vienna, Austria
--Andreas Brueckl--
OpenERP Consulting and Development
Andreas Brueckl
On 9/26/13, 10:36 AM

For date values in python and SQL you have to use the format %Y-%m-%d, e.g. "2013-09-26".

So I think the format of cont_start_date is not correct.

Hey Andreas, thanks for your reply. cont_start_date is a variable name. The actual value is exactly in the same format as you specified "2013-09-26". Please suggest me. Thanks

on 9/26/13, 10:41 AM

You only query whether there is a contract which starts before cont_start_date and ends after cont_end_date. If you want to see all overlapping contracts you have to consider also other cases!

Andreas Brueckl
on 9/26/13, 11:19 AM

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

0 follower(s)


Asked: 9/26/13, 9:46 AM
Seen: 1292 times
Last updated: 3/16/15, 8:10 AM