Odoo Help


list index out of range

on 1/19/15, 6:50 AM 536 views

Hi all,

def onchange_start_date_past(self, cr, uid, ids, start_date, eofdate, context=None):
chng_year = datetime.datetime.strptime(start_date, "%Y-%m-%d %H:%M:%S")
holiday_line_id = self.browse(cr, uid, ids[0], context=context).holiday_line_id
chng_year =  self.pool.get('holiday').browse(cr, uid, holiday_line_id.id, context=context).year
if chng_year != year:    
raise osv.except_osv(_('Warning!'),_('Please enter correct Year.'))
return super(year, self).unlink(cr, uid, ids, context=context)


i am getting issue in line num 3. that is "list index out of range".

what is the issue in parameter given.


If the record is not saved than in onchange method you will not receive any of the 'ids', it will be an empty or False, therefore it is throwing that error to you. You should check if there is anything in the 'ids' or not. Once the record is saved than you will receive the value in ids.


Hope this helps !!.

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: 1/19/15, 6:50 AM
Seen: 536 times
Last updated: 3/16/15, 8:10 AM