From df95f376beefa0adb1ed4144f6364ea56432a32d Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Tue, 10 Dec 2013 14:13:09 +0530 Subject: [PATCH] [IMP] improved messages: post message in job bzr revid: tpa@tinyerp.com-20131210084309-7t46f2vsutcdhkpc --- addons/hr_recruitment/hr_recruitment.py | 13 +++++++++---- addons/hr_recruitment/hr_recruitment_data.xml | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index 23eeb4a5793..1fb739f693e 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -83,10 +83,12 @@ class hr_applicant(osv.Model): _inherit = ['mail.thread', 'ir.needaction_mixin'] _track = { 'stage_id': { - # this is only an heuristics; depending on your particular stage configuration it may not match all 'new' stages - 'hr_recruitment.mt_applicant_new': lambda self, cr, uid, obj, ctx=None: obj.stage_id and obj.stage_id.sequence <= 1, + # this is only an heuristics; depending on your particular stage configuration it may not match all 'new' stages 'hr_recruitment.mt_applicant_stage_changed': lambda self, cr, uid, obj, ctx=None: obj.stage_id and obj.stage_id.sequence > 1, }, + 'job_id': { + 'hr_recruitment.mt_applicant_new': lambda self, cr, uid, obj, ctx=None: obj.job_id and obj.job_id.id, + }, } def _get_default_department_id(self, cr, uid, context=None): @@ -363,7 +365,8 @@ class hr_applicant(osv.Model): context = {} if vals.get('department_id') and not context.get('default_department_id'): context['default_department_id'] = vals.get('department_id') - + if vals.get('job_id'): + self.pool['hr.job'].message_post(cr, uid, [vals['job_id']], body=_('New Applicant %s Created') % vals['name'], subtype="hr_recruitment.mt_applicant_new", context=context) obj_id = super(hr_applicant, self).create(cr, uid, vals, context=context) return obj_id @@ -380,6 +383,8 @@ class hr_applicant(osv.Model): vals['last_stage_id'] = applicant.stage_id.id res = super(hr_applicant, self).write(cr, uid, [applicant.id], vals, context=context) return res + if vals.get('job_id'): + self.pool['hr.job'].message_post(cr, uid, [vals['job_id']], body=_('New Applicant %s Created') % vals['name'], subtype="hr_recruitment.mt_applicant_new", context=context) return super(hr_applicant, self).write(cr, uid, ids, vals, context=context) def create_employee_from_applicant(self, cr, uid, ids, context=None): @@ -403,7 +408,7 @@ class hr_applicant(osv.Model): 'department_id': applicant.department_id.id }) self.write(cr, uid, [applicant.id], {'emp_id': emp_id}, context=context) - self.message_post(cr, uid, [applicant.id], body=_('Applicant Hired'), subtype="hr_recruitment.mt_applicant_employee", context=context) + self.pool['hr.job'].message_post(cr, uid, [applicant.job_id.id], body=_('New Employee %s Hired') % applicant.partner_name, subtype="hr_recruitment.mt_applicant_employee", context=context) else: raise osv.except_osv(_('Warning!'), _('You must define an Applied Job and a Contact Name for this applicant.')) diff --git a/addons/hr_recruitment/hr_recruitment_data.xml b/addons/hr_recruitment/hr_recruitment_data.xml index b9732d92e8f..860c347cdd0 100644 --- a/addons/hr_recruitment/hr_recruitment_data.xml +++ b/addons/hr_recruitment/hr_recruitment_data.xml @@ -486,7 +486,7 @@ New Applicants hr.job - Applicant created + Applicant Created