From e21681633ce060683ff976b5972c0a76a164d3de Mon Sep 17 00:00:00 2001 From: "Darshan Kalola (OpenERP)" Date: Mon, 9 Sep 2013 15:29:57 +0530 Subject: [PATCH] [IMP]add help,ipmrove code and remove duplication in record_ids bzr revid: dka@tinyerp.com-20130909095957-a2gvivlto7qwv50x --- addons/hr_applicant_document/hr_applicant_document.py | 11 ++++++----- addons/hr_recruitment/hr_recruitment.py | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/addons/hr_applicant_document/hr_applicant_document.py b/addons/hr_applicant_document/hr_applicant_document.py index f5762aabfcc..45931478f26 100644 --- a/addons/hr_applicant_document/hr_applicant_document.py +++ b/addons/hr_applicant_document/hr_applicant_document.py @@ -26,12 +26,12 @@ class hr_applicant(osv.osv): def _get_index_content(self, cr, uid, ids, fields, args, context=None): res = {} attachment_pool = self.pool.get('ir.attachment') - for applicant in self.browse(cr, uid, ids, context=context): - res[applicant.id] = 0 - attachment_ids = attachment_pool.search(cr, uid, [('res_model','=','hr.applicant'),('res_id','=',applicant.id)], context=context) + for id in ids: + res[id] = 0 + attachment_ids = attachment_pool.search(cr, uid, [('res_model','=','hr.applicant'),('res_id','=',id)], context=context) if attachment_ids: for attachment in attachment_pool.browse(cr, uid, attachment_ids, context=context): - res[applicant.id] = attachment.index_content + res[id] = attachment.index_content return res def _content_search(self, cursor, user, obj, name, args, context=None): @@ -40,7 +40,8 @@ class hr_applicant(osv.osv): args += [('res_model','=','hr.applicant')] attachment_ids = attachment_pool.search(cursor, user, args, context=context) for attachment in attachment_pool.browse(cursor, user, attachment_ids, context=context): - record_ids.append(attachment.res_id) + if attachment.res_id not in record_ids: + record_ids.append(attachment.res_id) return [('id', 'in', record_ids)] _columns = { diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index e7a87ce7241..3ca69fc6289 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -239,7 +239,7 @@ class hr_applicant(osv.Model): 'day_close': fields.function(_compute_day, string='Days to Close', \ multi='day_close', type="float", store=True), 'color': fields.integer('Color Index'), - 'emp_id': fields.many2one('hr.employee', 'Employee'), + 'emp_id': fields.many2one('hr.employee', string='Employee', help='Employee linked to the applicant.'), 'attachments': fields.function(_compute_attachments, string='Number of Attachments', \ type="integer"), 'user_email': fields.related('user_id', 'email', type='char', string='User Email', readonly=True),