diff --git a/addons/crm/crm.py b/addons/crm/crm.py
index 7eec2a5015a..1020e77d775 100644
--- a/addons/crm/crm.py
+++ b/addons/crm/crm.py
@@ -258,25 +258,38 @@ class crm_base(object):
data.update(self.onchange_partner_address_id(cr, uid, ids, addr['contact'])['value'])
return {'value': data}
+ def case_get_note_msg_prefix(self, cr, uid, id, context=None):
+ return ''
+
def case_open_send_note(self, cr, uid, ids, context=None):
- msg = '%s has been opened.' % (context['msg_prefix'] if context['msg_prefix'] else '')
- return self.message_append_note(cr, uid, ids, 'System Notification', msg, context=context)
+ for id in ids:
+ msg = '%s has been opened.' % (self.case_get_note_msg_prefix(cr, uid, id, context=context))
+ self.message_append_note(cr, uid, [id], 'System Notification', msg, context=context)
+ return True
def case_close_send_note(self, cr, uid, ids, context=None):
- msg = '%s has been closed.' % (context['msg_prefix'] if context['msg_prefix'] else '')
- return self.message_append_note(cr, uid, ids, 'System Notification', msg, context=context)
+ for id in ids:
+ msg = '%s has been closed.'% (self.case_get_note_msg_prefix(cr, uid, id, context=context))
+ self.message_append_note(cr, uid, [id], 'System Notification', msg, context=context)
+ return True
def case_cancel_send_note(self, cr, uid, ids, context=None):
- msg = '%s has been canceled.' % (context['msg_prefix'] if context['msg_prefix'] else '')
- return self.message_append_note(cr, uid, ids, 'System Notification', msg, context=context)
+ for id in ids:
+ msg = '%s has been canceled.' % (self.case_get_note_msg_prefix(cr, uid, id, context=context))
+ self.message_append_note(cr, uid, [id], 'System Notification', msg, context=context)
+ return True
def case_pending_send_note(self, cr, uid, ids, context=None):
- msg = '%s is now pending.' % (context['msg_prefix'] if context['msg_prefix'] else '')
- return self.message_append_note(cr, uid, ids, 'System Notification', msg, context=context)
+ for id in ids:
+ msg = '%s is now pending.' % (self.case_get_note_msg_prefix(cr, uid, id, context=context))
+ self.message_append_note(cr, uid, [id], 'System Notification', msg, context=context)
+ return True
def case_reset_send_note(self, cr, uid, ids, context=None):
- msg = '%s has been renewed.' % (context['msg_prefix'] if context['msg_prefix'] else '')
- return self.message_append_note(cr, uid, ids, 'System Notification', msg, context=context)
+ for id in ids:
+ msg = '%s has been renewed.' % (self.case_get_note_msg_prefix(cr, uid, id, context=context))
+ self.message_append_note(cr, uid, [id], 'System Notification', msg, context=context)
+ return True
def case_open(self, cr, uid, ids, context=None):
"""Opens Case
diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py
index f5dffebb436..3eb82db9834 100644
--- a/addons/crm/crm_lead.py
+++ b/addons/crm/crm_lead.py
@@ -287,37 +287,9 @@ class crm_lead(crm_case, osv.osv):
message, type='notification', context=context)
return True
- def case_open_send_note(self, cr, uid, ids, context=None):
- for lead in self.browse(cr, uid, ids, context=context):
- if lead.state == 'draft' and lead.state == 'pending':
- continue
- context['msg_prefix'] = 'Opportunity' if lead.type == 'opportunity' else 'Lead'
- super(crm_lead, self).case_open_send_note(cr, uid, [lead.id], context=context)
- return True
-
- def case_close_send_note(self, cr, uid, ids, context=None):
- for lead in self.browse(cr, uid, ids, context=context):
- context['msg_prefix'] = 'Opportunity' if lead.type == 'opportunity' else 'Lead'
- super(crm_lead, self).case_close_send_note(cr, uid, ids, context=context)
- return True
-
- def case_cancel_send_note(self, cr, uid, ids, context=None):
- for lead in self.browse(cr, uid, ids, context=context):
- context['msg_prefix'] = 'Opportunity' if lead.type == 'opportunity' else 'Lead'
- super(crm_lead, self).case_cancel_send_note(cr, uid, ids, context=context)
- return True
-
- def case_pending_send_note(self, cr, uid, ids, context=None):
- for lead in self.browse(cr, uid, ids, context=context):
- context['msg_prefix'] = 'Opportunity' if lead.type == 'opportunity' else 'Lead'
- super(crm_lead, self).case_pending_send_note(cr, uid, ids, context=context)
- return True
-
- def case_reset_send_note(self, cr, uid, ids, context=None):
- for lead in self.browse(cr, uid, ids, context=context):
- context['msg_prefix'] = 'Opportunity' if lead.type == 'opportunity' else 'Lead'
- super(crm_lead, self).case_reset_send_note(cr, uid, ids, context=context)
- return True
+ def case_get_note_msg_prefix(self, cr, uid, id, context=None):
+ lead = self.browse(cr, uid, [id], context=context)[0]
+ return ('Opportunity' if lead.type == 'opportunity' else 'Lead')
def case_mark_lost_send_note(self, cr, uid, ids, context=None):
for opportunity in self.browse(cr, uid, ids, context=context):