diff options
| author | Thibault Delavallée <tde@openerp.com> | 2014-01-06 14:57:00 +0100 |
|---|---|---|
| committer | Thibault Delavallée <tde@openerp.com> | 2014-01-06 14:57:00 +0100 |
| commit | 49c0b7a82003a889edc19cb189d0d6d0ebda2c5f (patch) | |
| tree | d24c9d3fe3baad3ba06f11d4bf334e2504fb6092 /addons/hr_applicant_document/models | |
| parent | c4c268c902a134efdf0f097053c9b28d6b14417c (diff) | |
| parent | ced63415b7319e12fb9d31a3e370850278f697c1 (diff) | |
[MERGE] Sync with trunk
bzr revid: tde@openerp.com-20140106135700-rt0g44w5xmpbtxiu
Diffstat (limited to 'addons/hr_applicant_document/models')
| -rw-r--r-- | addons/hr_applicant_document/models/__init__.py | 3 | ||||
| -rw-r--r-- | addons/hr_applicant_document/models/hr_applicant.py | 29 |
2 files changed, 32 insertions, 0 deletions
diff --git a/addons/hr_applicant_document/models/__init__.py b/addons/hr_applicant_document/models/__init__.py new file mode 100644 index 00000000000..0f3aa35f140 --- /dev/null +++ b/addons/hr_applicant_document/models/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +import hr_applicant diff --git a/addons/hr_applicant_document/models/hr_applicant.py b/addons/hr_applicant_document/models/hr_applicant.py new file mode 100644 index 00000000000..036ea6c200e --- /dev/null +++ b/addons/hr_applicant_document/models/hr_applicant.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- + +from openerp.osv import fields, osv + + +class hr_applicant(osv.Model): + _inherit = 'hr.applicant' + + def _get_index_content(self, cr, uid, ids, fields, args, context=None): + res = dict.fromkeys(ids, '') + Attachment = self.pool.get('ir.attachment') + attachment_ids = Attachment.search(cr, uid, [('res_model', '=', 'hr.applicant'), ('res_id', 'in', ids)], context=context) + for attachment in Attachment.browse(cr, uid, attachment_ids, context=context): + res[attachment.res_id] += attachment.index_content or '' + return res + + def _content_search(self, cr, user, obj, name, args, context=None): + record_ids = set() + Attachment = self.pool.get('ir.attachment') + args = ['&'] + args + [('res_model', '=', 'hr.applicant')] + att_ids = Attachment.search(cr, user, args, context=context) + record_ids = set(att.res_id for att in Attachment.browse(cr, user, att_ids, context=context)) + return [('id', 'in', list(record_ids))] + + _columns = { + 'index_content': fields.function( + _get_index_content, fnct_search=_content_search, + string='Index Content', type="text"), + } |
