1 # -*- coding: utf-8 -*-
3 from openerp.osv import fields, osv
6 class hr_applicant(osv.Model):
7 _inherit = 'hr.applicant'
9 def _get_index_content(self, cr, uid, ids, fields, args, context=None):
10 res = dict.fromkeys(ids, '')
11 Attachment = self.pool.get('ir.attachment')
12 attachment_ids = Attachment.search(cr, uid, [('res_model', '=', 'hr.applicant'), ('res_id', 'in', ids)], context=context)
13 for attachment in Attachment.browse(cr, uid, attachment_ids, context=context):
14 res[attachment.res_id] += attachment.index_content or ''
17 def _content_search(self, cr, user, obj, name, args, context=None):
19 Attachment = self.pool.get('ir.attachment')
20 args = ['&'] + args + [('res_model', '=', 'hr.applicant')]
21 att_ids = Attachment.search(cr, user, args, context=context)
22 record_ids = set(att.res_id for att in Attachment.browse(cr, user, att_ids, context=context))
23 return [('id', 'in', list(record_ids))]
26 'index_content': fields.function(
27 _get_index_content, fnct_search=_content_search,
28 string='Index Content', type="text"),