[IMP]Improved the demo data for template to send mail and now mails are sent when Refuse application or Contract signed
bzr revid: dhr@tinyerp.com-20130318062044-0qmp56vibva2fcra
This commit is contained in:
parent
2ae7717edb
commit
0306b355d0
|
@ -442,6 +442,11 @@ class hr_applicant(base_stage, osv.Model):
|
|||
|
||||
def case_close(self, cr, uid, ids, context=None):
|
||||
res = super(hr_applicant, self).case_close(cr, uid, ids, context)
|
||||
try:
|
||||
template = self.pool.get('ir.model.data').get_object(cr, uid, 'hr_recruitment', 'email_template_approve_applicant')
|
||||
except ValueError:
|
||||
pass
|
||||
self._get_mail_template(cr, uid, ids, template, context)
|
||||
return res
|
||||
|
||||
def case_close_with_emp(self, cr, uid, ids, context=None):
|
||||
|
@ -483,8 +488,24 @@ class hr_applicant(base_stage, osv.Model):
|
|||
"""
|
||||
res = super(hr_applicant, self).case_cancel(cr, uid, ids, context)
|
||||
self.write(cr, uid, ids, {'probability': 0.0})
|
||||
template = False
|
||||
try:
|
||||
template = self.pool.get('ir.model.data').get_object(cr, uid, 'hr_recruitment', 'email_template_refuse_applicant')
|
||||
except ValueError:
|
||||
pass
|
||||
self._get_mail_template(cr, uid, ids, template, context)
|
||||
return res
|
||||
|
||||
|
||||
def _get_mail_template(self, cr, uid, ids, template, context):
|
||||
mail_obj = self.pool.get('mail.mail')
|
||||
assert template._name == 'email.template'
|
||||
for applications in self.browse(cr, uid, ids, context):
|
||||
if applications.email_from:
|
||||
mail_id = self.pool.get('email.template').send_mail(cr, uid, template.id, applications.id, True, context=context)
|
||||
mail_state = mail_obj.read(cr, uid, mail_id, ['state'], context=context)
|
||||
if mail_state and mail_state['state'] == 'exception':
|
||||
raise self.pool.get('res.config.settings').get_config_warning(cr, _("Cannot send email: no outgoing email server configured.\nYou can configure it under %(menu:base_setup.menu_general_configuration)s."), context)
|
||||
|
||||
def case_pending(self, cr, uid, ids, context=None):
|
||||
"""Marks case as pending"""
|
||||
res = super(hr_applicant, self).case_pending(cr, uid, ids, context)
|
||||
|
|
|
@ -220,7 +220,7 @@
|
|||
|
||||
<record id="email_template_refuse_applicant" model="email.template">
|
||||
<field name="name">Refuse Application</field>
|
||||
<field name="email_from">${object.user.email or ''}</field>
|
||||
<field name="email_from">${user.email or ''}</field>
|
||||
<field name="subject">We refuse your application</field>
|
||||
<field name="email_to">${object.email_from}</field>
|
||||
<field name="lang">${object.lang}</field>
|
||||
|
@ -238,8 +238,8 @@
|
|||
|
||||
<record id="email_template_approve_applicant" model="email.template">
|
||||
<field name="name">Interested in Application</field>
|
||||
<field name="email_from">${object.user.email or ''}</field>
|
||||
<field name="email_to">{object.email_from}</field>
|
||||
<field name="email_from">${user.email or ''}</field>
|
||||
<field name="email_to">${object.email_from}</field>
|
||||
<field name="subject">We are interested in your application</field>
|
||||
<field name="lang">${object.lang}</field>
|
||||
<field name="model_id" ref="hr_recruitment.model_hr_applicant"/>
|
||||
|
|
Loading…
Reference in New Issue