Odoo Help

0

How to resolve list index error ..Please check code and need a help

By
Odoo
on 6/11/14, 10:54 PM 854 views

 


IndexError: list index out of range need a help  When I click on def  check_eligibility function error is occurs

 

_name='hr.employee'
     _inherit=['hr.employee','mail.thread']

     _columns={
              'date_of_join' :fields.date('Date of Join',required=True),
              'current_date':fields.date('Applied date',require=True),
              'eligible_details':fields.char('Eligibility Details'),
              'visaexpiry_date':fields.date('Visa Expiry Date'),
               'residence_expiry_date':fields.date('Residence Expiry',required=True),
               'work_permit_date':fields.date('Work Permit'),
               'insurance_expiry_date':fields.date('Insurance date'),
               'license_date':fields.date('License date',required=True)
                             }


def  check_eligibility(self,cr,uid,ids,context=None):
         day_obj=self.read(cr,uid,ids,['date_of_join','current_date'],context=context)
     print "day_obj#############################",day_obj
         
         calc_vacation=self.pool.get('scheme.type.info').read(cr,uid,ids,['interval','criteria','scheme_id'],context=context)
     print "day_obj#############################",calc_vacation
         
         
         dateformat="%Y-%m-%d"
         d1=datetime.strptime(day_obj[0]['date_of_join'],dateformat)
         d2=datetime.strptime(day_obj[0]['current_date'],dateformat)
         v1=d2-d1
         
         total_days=v1.days
       
         if total_days<=calc_vacation[0]['interval'] and calc_vacation[0]['scheme_id']==1 :
             msg=calc_vacation[0]['criteria']
         elif total_days<=calc_vacation[0]['interval'] and calc_vacation[0]['scheme_id']==2:
              msg=calc_vacation[0]['criteria']
         else:
             msg="You are not eligible"
         vals={
               'eligible_details':msg
               }
         self.write(cr,uid,ids,vals)
        
         return True


     
class scheme_type_info(osv.osv):
    
    _name='scheme.type.info'
    
    _columns={
              'scheme_id':fields.integer('Scheme Type',required=True,size=50),
              'interval':fields.integer('interval type ',required=True,size=64),
              'criteria':fields.text('vacation criteria',required=True,size=50),
              'active':fields.boolean('Active')
              }
    
scheme_type_info()

 

 

 

 

 

---------------------

This is the values inside day_obj some time it have not  values , some time it have

day_obj############################# [{'current_date': '2014-06-19', 'date_of_join': '2014-06-04', 'id': 7, 'resource_id': 7}]
day_obj############################# []

 

 

day_obj############################# [{'current_date': '2019-06-27', 'date_of_join': '2014-06-11', 'id': 2, 'resource_id': 2}]
day_obj############################# [{'interval': 300, 'id': 2, 'scheme_id': 2, 'criteria': u'tfggt'}]

 

 

0
Ludo - Neobis
On 6/12/14, 3:13 AM

This issue is a duplicate of :

https://www.odoo.com/forum/Help-1/question/IndexError-list-index-out-of-range-need-a-help-54036#answer-54046

Over there, both user Hiren Vora and me gave you an answer. I think you need to check those answers and will find that the solution is apparent. If you are unable to fix it yourself, maybe consult another (indian) developer who is able to work with you on-site?

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: 6/11/14, 10:54 PM
Seen: 854 times
Last updated: 3/16/15, 8:10 AM