[IMP] improves the reporting view Expenses Analysis (add some measures to the table...
[odoo/odoo.git] / addons / hr_applicant_document / models / hr_applicant.py
1 # -*- coding: utf-8 -*-
2
3 from openerp.osv import fields, osv
4
5
6 class hr_applicant(osv.Model):
7     _inherit = 'hr.applicant'
8
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 ''
15         return res
16
17     def _content_search(self, cr, user, obj, name, args, context=None):
18         record_ids = set()
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))]
24
25     _columns = {
26         'index_content': fields.function(
27             _get_index_content, fnct_search=_content_search,
28             string='Index Content', type="text"),
29     }