diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py
index da845cc8e5f..b02369cce9f 100644
--- a/addons/crm/crm_lead.py
+++ b/addons/crm/crm_lead.py
@@ -865,7 +865,9 @@ class crm_lead(base_stage, osv.osv):
def stage_set_send_note(self, cr, uid, ids, stage_id, context=None):
""" Override of the (void) default notification method. """
stage_name = self.pool.get('crm.case.stage').name_get(cr, uid, [stage_id], context=context)[0][1]
- return self.message_append_note(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), context=context)
+ res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm', 'mail_subtype_lead_stage_change')
+ res_id = res[1]
+ return self.message_append_note(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_id=res_id,context=context)
def case_get_note_msg_prefix(self, cr, uid, lead, context=None):
if isinstance(lead, (int, long)):
@@ -875,33 +877,45 @@ class crm_lead(base_stage, osv.osv):
def create_send_note(self, cr, uid, ids, context=None):
for id in ids:
message = _("%s has been created.")% (self.case_get_note_msg_prefix(cr, uid, id, context=context))
- self.message_append_note(cr, uid, [id], body=message, context=context)
+ res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm', 'mail_subtype_lead_new')
+ res_id = res[1]
+ self.message_append_note(cr, uid, [id], body=message, subtype_id=res_id, context=context)
return True
def case_mark_lost_send_note(self, cr, uid, ids, context=None):
message = _("Opportunity has been lost.")
- return self.message_append_note(cr, uid, ids, body=message, context=context)
+ res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm', 'mail_subtype_lead_lost')
+ res_id = res[1]
+ return self.message_append_note(cr, uid, ids, body=message,subtype_id=res_id, context=context)
def case_mark_won_send_note(self, cr, uid, ids, context=None):
message = _("Opportunity has been won.")
- return self.message_append_note(cr, uid, ids, body=message, context=context)
+ res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm', 'mail_subtype_lead_won')
+ res_id = res[1]
+ return self.message_append_note(cr, uid, ids, body=message, subtype_id=res_id, context=context)
def schedule_phonecall_send_note(self, cr, uid, ids, phonecall_id, action, context=None):
phonecall = self.pool.get('crm.phonecall').browse(cr, uid, [phonecall_id], context=context)[0]
if action == 'log': prefix = 'Logged'
else: prefix = 'Scheduled'
message = _("%s a call for the %s.") % (prefix, phonecall.date)
- return self.message_append_note(cr, uid, ids, body=message, context=context)
+ res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm', 'mail_subtype_lead_other')
+ res_id = res[1]
+ return self.message_append_note(cr, uid, ids, body=message, subtype_id=res_id, context=context)
def _lead_set_partner_send_note(self, cr, uid, ids, context=None):
for lead in self.browse(cr, uid, ids, context=context):
message = _("%s partner is now set to %s." % (self.case_get_note_msg_prefix(cr, uid, lead, context=context), lead.partner_id.name))
- lead.message_append_note(body=message)
+ res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm', 'mail_subtype_lead_other')
+ res_id = res[1]
+ lead.message_append_note(body=message, subtype_id=res_id)
return True
def convert_opportunity_send_note(self, cr, uid, lead, context=None):
message = _("Lead has been converted to an opportunity.")
- lead.message_append_note(body=message)
+ res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm', 'mail_subtype_lead_other')
+ res_id = res[1]
+ lead.message_append_note(body=message, subtype_id=res_id)
return True
crm_lead()
diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py
index 79b734379d0..14e9138be55 100644
--- a/addons/mail/mail_thread.py
+++ b/addons/mail/mail_thread.py
@@ -335,6 +335,7 @@ class mail_thread(osv.Model):
'parent_id': parent_id,
'date': email_date or fields.datetime.now(),
'type': type,
+ 'subtype_id' : subtype_id,
'content_subtype': content_subtype,
'state': state,
'message_id': message_id,
@@ -866,7 +867,7 @@ class mail_thread(osv.Model):
now deprecated res.log.")
self.message_append_note(cr, uid, [id], 'res.log', message, context=context)
- def message_append_note(self, cr, uid, ids, subject=None, subtype_id=None, body=None, parent_id=False,
+ def message_append_note(self, cr, uid, ids, subject=None, subtype_id=False, body=None, parent_id=False,
type='notification', content_subtype='html', context=None):
if content_subtype == 'html':
body_html = body