diff --git a/addons/hr_recruitment/models/hr_recruitment.py b/addons/hr_recruitment/models/hr_recruitment.py
index c8ae303f705..6c4cbac60da 100644
--- a/addons/hr_recruitment/models/hr_recruitment.py
+++ b/addons/hr_recruitment/models/hr_recruitment.py
@@ -289,11 +289,6 @@ class Applicant(models.Model):
res = super(Applicant, self).write(vals)
else:
res = super(Applicant, self).write(vals)
-
- # post processing: if stage changed, post a message in the chatter
- if vals.get('stage_id'):
- if self.stage_id.template_id:
- self.message_post_with_template(self.stage_id.template_id.id, notify=True, composition_mode='mass_mail')
return res
@api.model
@@ -358,6 +353,15 @@ class Applicant(models.Model):
action['domain'] = str(['&', ('res_model', '=', self._name), ('res_id', 'in', self.ids)])
return action
+ @api.multi
+ def _track_template(self, tracking):
+ res = super(Applicant, self)._track_template(tracking)
+ applicant = self[0]
+ changes, dummy = tracking[applicant.id]
+ if 'stage_id' in changes and applicant.stage_id.template_id:
+ res['stage_id'] = (applicant.stage_id.template_id, {'composition_mode': 'mass_mail'})
+ return res
+
@api.multi
def _track_subtype(self, init_values):
record = self[0]
diff --git a/addons/project/project.py b/addons/project/project.py
index 46ba4ba1e5f..f9889a152cf 100644
--- a/addons/project/project.py
+++ b/addons/project/project.py
@@ -18,6 +18,10 @@ class project_task_type(osv.osv):
_name = 'project.task.type'
_description = 'Task Stage'
_order = 'sequence'
+
+ def _get_mail_template_id_domain(self):
+ return [('model', '=', 'project.task')]
+
_columns = {
'name': fields.char('Stage Name', required=True, translate=True),
'description': fields.text('Description', translate=True),
@@ -35,6 +39,11 @@ class project_task_type(osv.osv):
'legend_normal': fields.char(
'Kanban Ongoing Explanation', translate=True,
help='Override the default value displayed for the normal state for kanban selection, when the task or issue is in that stage.'),
+ 'mail_template_id': fields.many2one(
+ 'mail.template',
+ string='Email Template',
+ domain=lambda self: self._get_mail_template_id_domain(),
+ help="If set an email will be sent to the customer when the task or issue reaches this step."),
'fold': fields.boolean('Folded in Tasks Pipeline',
help='This stage is folded in the kanban view when '
'there are no records in that stage to display.'),
@@ -713,6 +722,15 @@ class task(osv.osv):
# Mail gateway
# ---------------------------------------------------
+ @api.multi
+ def _track_template(self, tracking):
+ res = super(task, self)._track_template(tracking)
+ test_task = self[0]
+ changes, tracking_value_ids = tracking[test_task.id]
+ if 'stage_id' in changes and test_task.stage_id.mail_template_id:
+ res['stage_id'] = (test_task.stage_id.mail_template_id, {'composition_mode': 'mass_mail'})
+ return res
+
def _track_subtype(self, cr, uid, ids, init_values, context=None):
record = self.browse(cr, uid, ids[0], context=context)
if 'kanban_state' in init_values and record.kanban_state == 'blocked':
diff --git a/addons/project/project_demo.xml b/addons/project/project_demo.xml
index bd2cd72cdb8..d424645c766 100644
--- a/addons/project/project_demo.xml
+++ b/addons/project/project_demo.xml
@@ -21,12 +21,27 @@
Thank you for your enquiry.
If you have any questions, please let us know.
+Best regards,
]]> +