From dca6a4575e5f32bcab26d5fdc18713174f4f6dc4 Mon Sep 17 00:00:00 2001 From: "Chirag Dodiya (OpenERP Trainee)" Date: Wed, 4 Sep 2013 18:58:08 +0530 Subject: [PATCH] [IMP] Improved form view of Job Position as per suggestion bzr revid: chiragdd7@gmail.com-20130904132808-clg5cbx6r5g5mv3u --- addons/hr/hr_view.xml | 4 ++-- addons/hr_recruitment/hr_recruitment.py | 23 +++++++++++++++++++ addons/hr_recruitment/hr_recruitment_view.xml | 20 +++++++++------- .../static/src/css/job_position.css | 6 ++++- 4 files changed, 42 insertions(+), 11 deletions(-) diff --git a/addons/hr/hr_view.xml b/addons/hr/hr_view.xml index 42a2d75b618..267aacedb2d 100644 --- a/addons/hr/hr_view.xml +++ b/addons/hr/hr_view.xml @@ -350,11 +350,11 @@
- + diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index 2fe40699ffc..313bf4e5766 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -465,6 +465,14 @@ class hr_job(osv.osv): for applicant in applicant_obj.browse(cr, uid, applicant_ids, context=context): res[applicant.job_id.id] += 1 return res + + def _get_attached_docs(self, cr, uid, ids, field_name, arg, context): + res = {} + attachment = self.pool.get('ir.attachment') + for id in ids: + job_attachments = attachment.search(cr, uid, [('res_model', '=', 'hr.job'), ('res_id', '=', id)], context=context, count=True) + res[id] = (job_attachments or 0) + return res _columns = { 'survey_id': fields.many2one('survey', 'Interview Form', help="Choose an interview form for this job position and you will be able to print/answer this interview from all applicants who apply for this job"), @@ -473,6 +481,7 @@ class hr_job(osv.osv): "create new applicants for this job position."), 'application_count': fields.function(_application_count, type='integer', string="Total Applications"), 'manager_id': fields.related('department_id', 'manager_id', type='many2one', string='Department Manager', relation='hr.employee', readonly=True, store=True), + 'doc_count':fields.function(_get_attached_docs, string="Number of documents attached", type='int') } def _auto_init(self, cr, context=None): @@ -512,6 +521,20 @@ class hr_job(osv.osv): 'nodestroy': True, } + def attachment_tree_view(self, cr, uid, ids, context): + domain = ['&', ('res_model', '=', 'hr.job'), ('res_id', 'in', ids)] + res_id = ids and ids[0] or False + return { + 'name': _('Attachments'), + 'domain': domain, + 'res_model': 'ir.attachment', + 'type': 'ir.actions.act_window', + 'view_id': False, + 'view_mode': 'tree,form', + 'view_type': 'form', + 'limit': 80, + 'context': "{'default_res_model': '%s','default_res_id': %d}" % (self._name, res_id) + } class applicant_category(osv.osv): """ Category of applicant """ diff --git a/addons/hr_recruitment/hr_recruitment_view.xml b/addons/hr_recruitment/hr_recruitment_view.xml index afd1a8c6714..0e8f72429ae 100644 --- a/addons/hr_recruitment/hr_recruitment_view.xml +++ b/addons/hr_recruitment/hr_recruitment_view.xml @@ -338,24 +338,22 @@