[IMP]hr_recruitment: Replace hardcoded 'welcome message for new employee' with a email template.

This commit is contained in:
Ronak Baxi
2015-03-25 11:55:21 +01:00
committed by Jérome Maes
parent f516d39beb
commit bf9ca71abb
2 changed files with 27 additions and 6 deletions
+10 -6
View File
@@ -540,12 +540,16 @@ class hr_applicant(osv.Model):
def _broadcast_welcome(self, cr, uid, employee_id, context=None):
""" Broadcast the welcome message to all users in the employee company. """
employee = self.pool.get('hr.employee').browse(cr, uid, employee_id, context=context)
mail_group_action, mail_group_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'mail', 'group_all_employees')
self.pool.get('mail.group').message_post(
cr, uid, [mail_group_id],
body=_('Welcome to %s! Please help him/her take the first steps with Odoo!') % (employee.name),
subtype='mail.mt_comment', context=context)
IrModelData = self.pool['ir.model.data']
group_all_employees = IrModelData.xmlid_to_object(cr, uid, 'mail.group_all_employees', context=context)
template_new_employee = IrModelData.xmlid_to_object(cr, uid, 'hr_recruitment.hr_welcome_new_employee', context=context)
if template_new_employee:
MailTemplate = self.pool['mail.template']
body_html = MailTemplate.render_template(cr, uid, template_new_employee.body_html, 'hr.employee', employee_id, context=context)
subject = MailTemplate.render_template(cr, uid, template_new_employee.subject, 'hr.employee', employee_id, context=context)
self.pool['mail.group'].message_post(cr, uid, [group_all_employees.id],
body=body_html, subject=subject,
subtype='mail.mt_comment', context=context)
return True
def create_employee_from_applicant(self, cr, uid, ids, context=None):
@@ -36,6 +36,23 @@
${object.user_id and object.user_id.signature | safe or ''}]]></field>
</record>
<record id="hr_welcome_new_employee" model="mail.template">
<field name="name">Welcome New Employee</field>
<field name="model_id" ref="hr.model_hr_employee"/>
<field name="subject">Welcoming ${object.name} </field>
<field name="body_html"><![CDATA[
<p>
%if user.has_group('hr.group_multi_departments') and object.department_id:
I’m very pleased to announce that <strong> ${object.name} </strong> will be joining us as a ${object.job_id.name}
in ${object.department_id.name}.
%else:
I’m very pleased to announce that <strong> ${object.name} </strong> will be joining us as a ${object.job_id.name}.
%endif
</p>
<p>Please welcome him/her and help him/her finding his/her marks.</p>
]]></field>
</record>
<record id="applicant_interest" model="mail.template">
<field name="name">Application approved</field>
<field name="subject">Application approved</field>