From 94e6eb0f042f28e40ccb57ffaed9ffc59301ab85 Mon Sep 17 00:00:00 2001 From: "kum (Open ERP)" Date: Tue, 16 Mar 2010 19:03:09 +0530 Subject: [PATCH] [IMP] hr_evaluation:improved view,code and added email functionality bzr revid: kum@tinyerp.co.in-20100316133309-kwf4njt5d42wdvre --- addons/hr_evaluation/hr_evaluation.py | 51 +++++++++++++++++++++++++-- addons/hr_evaluation/hr_evaluation_view.xml | 11 ++++++ 2 files changed, 60 insertions(+), 2 deletions(-) diff --git a/addons/hr_evaluation/hr_evaluation.py b/addons/hr_evaluation/hr_evaluation.py index 057d60b..984536f 100644 --- a/addons/hr_evaluation/hr_evaluation.py +++ b/addons/hr_evaluation/hr_evaluation.py @@ -67,12 +67,33 @@ class hr_evaluation_plan_phase(osv.osv): help="Send an anonymous summary to the employee"), 'wait': fields.boolean('Wait Previous Phases', help="Check this box if you want to wait that all preceeding phases " + - "are finished before launching this phase.") - + "are finished before launching this phase."), + 'mail_feature': fields.boolean('Send mail for this phase',help="Check this box if you want to send mail to employees"+ + "coming under this phase"), + 'mail_body': fields.text('Email'), + 'email_subject':fields.text('char') } _defaults = { 'sequence' : lambda *a: 1, + 'email_subject':'''Regarding ''', + 'mail_body' : lambda *a:''' +Date : %(date)s + +Dear %(employee_name)s, + +I am doing an evaluation regarding %(eval_name)s. + +Kindly submit your response. + + +Thanks, +-- +%(user_signature)s + + ''', } + + hr_evaluation_plan_phase() class hr_employee(osv.osv): @@ -162,9 +183,11 @@ class hr_evaluation(osv.osv): return {'value': {'plan_id':evaluation_plan_id}} def button_plan_in_progress(self,cr, uid, ids, context={}): + user_obj = self.pool.get('res.users') employee_obj = self.pool.get('hr.employee') hr_eval_inter_obj = self.pool.get('hr.evaluation.interview') survey_request_obj = self.pool.get('survey.request') + hr_eval_plan_obj = self.pool.get('hr_evaluation.plan.phase') curr_employee=self.browse(cr,uid, ids, context=context)[0].employee_id child_employees=employee_obj.browse(cr,uid, employee_obj.search(cr,uid,[('parent_id','=',curr_employee.id)],context=context)) manager_employee=curr_employee.parent_id @@ -180,7 +203,24 @@ class hr_evaluation(osv.osv): id = hr_eval_inter_obj.create(cr, uid, {'evaluation_id':evaluation.id ,'user_id' : user,'survey_id' : phase.survey_id.id, 'user_to_review_id' : child.id, 'date_deadline' :(dt.ISO.ParseAny(dt.now().strftime('%Y-%m-%d')) + dt.RelativeDateTime(months =+ 1)).strftime('%Y-%m-%d')},context=context) if not phase.wait: hr_eval_inter_obj.survey_req_waiting_answer(cr, uid, [id], context=context) + if phase.mail_feature: + src = tools.config.options['email_from'] + user_obj_id = user_obj.browse(cr,uid,uid) + val = { + 'employee_name':child.name, + 'user_signature':curr_employee.name, + 'company_name':user_obj_id.company_id.name, + 'eval_name':phase.survey_id.title, + 'date':time.strftime('%Y-%m-%d'), + } + mailbody = hr_eval_plan_obj.read(cr,uid,phase.id,['mail_body','email_subject'],context=context) + body = mailbody['mail_body']%val + sub = mailbody['email_subject']+phase.survey_id.title + dest=[child.work_email] + if dest: + tools.email_send(src,dest,sub,body) apprai_id.append(id) + elif phase.action == "top-down": if manager_employee: user = False @@ -189,6 +229,13 @@ class hr_evaluation(osv.osv): id = hr_eval_inter_obj.create(cr, uid, {'evaluation_id':evaluation.id,'user_id': user ,'survey_id' : phase.survey_id.id, 'user_to_review_id' :manager_employee.id, 'date_deadline' :(dt.ISO.ParseAny(dt.now().strftime('%Y-%m-%d')) + dt.RelativeDateTime(months =+ 1)).strftime('%Y-%m-%d')},context=context) if not phase.wait: hr_eval_inter_obj.survey_req_waiting_answer(cr, uid, [id], context=context) + if phase.mail_feature: + val.update({'employee_name':manager_employee.name}) + mailbody = hr_eval_plan_obj.read(cr,uid,phase.id,['mail_body'],context=context) + body = mailbody['mail_body']%val + dest = [child.work_email] + if dest: + tools.email_send(src,dest,sub,body) apprai_id.append(id) elif phase.action == "self": if curr_employee: diff --git a/addons/hr_evaluation/hr_evaluation_view.xml b/addons/hr_evaluation/hr_evaluation_view.xml index 12f336e..a9b5606 100644 --- a/addons/hr_evaluation/hr_evaluation_view.xml +++ b/addons/hr_evaluation/hr_evaluation_view.xml @@ -57,6 +57,8 @@ form
+ + @@ -84,6 +86,15 @@ + + + + + + + + +
-- 1.7.10.4