0

I am Vaibhav new in open ERP 7 and got error while inheriting hr_recruitment module.

I override search method for hr_recruitment to filter out applications I added job_code char field in hr_job and job_code_applicant in hr_applicant

My code is :

def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
    ''' Overriden search method'''
    cur_obj=self.pool.get('hr.job')
    cr.execute('SELECT job_code FROM hr_job ')
    list = cr.fetchall()
    ids =  [ i[0] for i in list]
    cr.execute('SELECT id FROM hr_applicant WHERE job_code_applicant IN %s', (tuple(set(ids)),))
    list12 = cr.fetchall()
    ids_applicant =  [ i[0] for i in list12 ]
    return ids_applicant

Error is:

Traceback (most recent call last):

File "/home/fabian/openerp-7.0-20130408-232357/openerp/netsvc.py", line 293, in dispatch_rpc
result = ExportService.getService(service_name).dispatch(method, params)
File "/home/fabian/openerp-7.0-20130408-232357/openerp/service/web_services.py", line 626, in dispatch
res = fn(db, uid, *params)
File "/home/fabian/openerp-7.0-20130408-232357/openerp/osv/osv.py", line 188, in execute_kw
return self.execute(db, uid, obj, method, *args, **kw or {})
File "/home/fabian/openerp-7.0-20130408-232357/openerp/osv/osv.py", line 131, in wrapper
return f(self, dbname, *args, **kwargs)
File "/home/fabian/openerp-7.0-20130408-232357/openerp/osv/osv.py", line 197, in execute
res = self.execute_cr(cr, uid, obj, method, *args, **kw)
File "/home/fabian/openerp-7.0-20130408-232357/openerp/osv/osv.py", line 185, in execute_cr
return getattr(object, method)(cr, uid, *args, **kw)
File "/home/fabian/openerp-7.0-20130408-232357/openerp/osv/orm.py", line 2697, in read_group
d['__domain'] = [(groupby, '=', alldata[d['id']][groupby] or False)] + domain

KeyError: 8

skuntsel
  • 11,624
  • 11
  • 44
  • 67
vaibhav
  • 33
  • 1
  • 8
  • hr_recruitment is module. Here, I am assuming that you are overriding search method of hr.applicant object. but what do you want to do by overriding search ? On which base, you want to filter out applicants ? Please explain more! – Priyesh Solanki May 06 '13 at 07:18

1 Answers1

0

In your code why you not return super of search method instead of returning direclty ids?

Like:

def search(self, cr, uid, args, offset=0, limit=None, order=None,
                       context=None, count=False):
    #''' Overriden search method'''
    cur_obj=self.pool.get('hr.job')
    cr.execute('SELECT job_code '\
                 'FROM hr_job '\
              )
    list = cr.fetchall()
    ids =  [ i[0] for i in list]
    if ids:
        args.append(('job_code_applicant', 'in', ids))    

return super(hr_applicant, self).search(cr, uid, args, offset, limit, order, context, count)
user1576199
  • 3,217
  • 3
  • 20
  • 32