From 959445fa6963e00e4901d5aa5f1afa06c1cb31d4 Mon Sep 17 00:00:00 2001 From: "Jignesh Rathod (OpenERP)" Date: Tue, 11 Jun 2013 15:10:05 +0530 Subject: [PATCH] Code Improve. bzr revid: jir@tinyerp.com-20130611094005-tu13lpz6u837va0s --- addons/document/document_view.xml | 3 -- .../hr_applicant_document.py | 20 +++++++++--- .../hr_applicant_document_view.xml | 32 +++++++------------ 3 files changed, 26 insertions(+), 29 deletions(-) diff --git a/addons/document/document_view.xml b/addons/document/document_view.xml index 8c60e232dbf..c3bd5ad3f56 100644 --- a/addons/document/document_view.xml +++ b/addons/document/document_view.xml @@ -199,9 +199,6 @@ - - - diff --git a/addons/hr_applicant_document/hr_applicant_document.py b/addons/hr_applicant_document/hr_applicant_document.py index 5675d87d473..1b5144b7566 100644 --- a/addons/hr_applicant_document/hr_applicant_document.py +++ b/addons/hr_applicant_document/hr_applicant_document.py @@ -29,20 +29,30 @@ from openerp.tools import html2plaintext class applicant_document(osv.osv): _name = 'hr.applicant' _inherit = 'hr.applicant' + def _get_index_content(self, cr, uid, ids, fields, args, context=None): res = {} attachment_pool = self.pool.get('ir.attachment') - for issue in self.browse(cr, uid, ids, context=context): - res[issue.id] = 0 - attach_id = attachment_pool.search(cr, uid, [('res_model','=','hr.applicant'),('res_id','=',issue.id)]) + for applicant in self.browse(cr, uid, ids, context=context): + res[applicant.id] = 0 + attach_id = attachment_pool.search(cr, uid, [('res_model','=','hr.applicant'),('res_id','=',applicant.id)]) if attach_id: for attach in attachment_pool.browse(cr, uid, attach_id, context): - res[issue.id] = attach.index_content + res[applicant.id] = attach.index_content return res + def _content_search(self, cursor, user, obj, name, args, context=None): + record_ids = [] + attachment_pool = self.pool.get('ir.attachment') + args += [('res_model','=','hr.applicant')] + attach_ids = attachment_pool.search(cursor, user, args) + for attach in attachment_pool.browse(cursor, user, attach_ids): + record_ids.append(attach.res_id) + return [('id', 'in', record_ids)] + _columns = { 'index_content': fields.function(_get_index_content, string='Index Content', \ - type="char",store=True), + fnct_search=_content_search,type="text"), } applicant_document() diff --git a/addons/hr_applicant_document/hr_applicant_document_view.xml b/addons/hr_applicant_document/hr_applicant_document_view.xml index c590c5c89fe..ed373831f85 100644 --- a/addons/hr_applicant_document/hr_applicant_document_view.xml +++ b/addons/hr_applicant_document/hr_applicant_document_view.xml @@ -2,27 +2,17 @@ - - Applicants - hr.applicant - - - - - - - - - - Jobs - Recruitment Search - hr.applicant - - - - - - - + + + Jobs - Recruitment Search + hr.applicant + + + + + + +