[IMP] Improved default message in crm_base. Inheriting classes only have to redefine a case_get_note_msg_prefix if using the default crm_base messages.

bzr revid: tdelavallee@gmail.com-20120315205128-qeedjxrmscu4fafm
This commit is contained in:
Georges Grogero
2012-03-15 21:51:28 +01:00
parent 1a0a7310a8
commit 0fbc4084ff
2 changed files with 26 additions and 41 deletions
+23 -10
View File
@@ -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 <b>opened</b>.' % (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 <b>opened</b>.' % (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 <b>closed</b>.' % (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 <b>closed</b>.'% (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 <b>canceled</b>.' % (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 <b>canceled</b>.' % (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 <b>pending</b>.' % (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 <b>pending</b>.' % (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 <b>renewed</b>.' % (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 <b>renewed</b>.' % (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
+3 -31
View File
@@ -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):