[CLEAN] mail: comment xml_id is now mt_comment. Propagated change. Slighty cleaned code in base_status.

bzr revid: tde@openerp.com-20120919114353-8s9lo6tp78tnwj56
This commit is contained in:
Thibault Delavallée 2012-09-19 13:43:53 +02:00
parent fa27dde6c9
commit 64672b1764
5 changed files with 18 additions and 19 deletions

View File

@ -349,6 +349,15 @@ class base_stage(object):
"""
return ''
def find_subtype_xml_id(self, cr, uid, ids, name, context=None):
ir_model_data_obj = self.pool.get('ir.model.data')
subtype_ids = self.pool.get('mail.message.subtype').search(cr, uid, [('res_model', '=', self._name), ('name', '=', name)], context=context)
ir_data_ids = ir_model_data_obj.search(cr, uid, [('model', '=', 'mail.message.subtype'), ('res_id', 'in', subtype_ids)], context=context)
ir_model_data_record = ir_model_data_obj.browse(cr, uid, ir_data_ids, context=context)
if ir_model_data_record:
return ir_model_data_record[0].name
return None
def stage_set_send_note(self, cr, uid, ids, stage_id, context=None):
""" Send a notification when the stage changes. This method has
to be overriden, because each document will have its particular
@ -360,31 +369,21 @@ class base_stage(object):
def case_open_send_note(self, cr, uid, ids, context=None):
for id in ids:
msg = _('%s has been <b>opened</b>.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context))
self.message_post(cr, uid, [id], body=msg, context=context)
xml_id = self.find_subtype_xml_id(cr, uid, ids, name="open", context=context)
self.message_post(cr, uid, [id], body=msg, subtype_xml_id=xml_id, context=context)
return True
def find_xml_id(self,cr,uid,ids,name,context=None):
subtype_obj = self.pool.get('mail.message.subtype')
ir_model_data_obj = self.pool.get('ir.model.data')
subtype_ids = subtype_obj.search(cr,uid,[('res_model','=',self._name),('name','=',name)])
ir_data_ids = ir_model_data_obj.search(cr,uid,[('model','=','mail.message.subtype'),('res_id','in',subtype_ids)])
xml_id = 'mail_subtype_comment'
ir_model_data_record = ir_model_data_obj.browse(cr,uid,ir_data_ids)
if ir_model_data_record:
xml_id = ir_model_data_record[0].name
return xml_id
def case_close_send_note(self, cr, uid, ids, context=None):
for id in ids:
msg = _('%s has been <b>closed</b>.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context))
xml_id = self.find_xml_id(cr, uid, ids, name="closed", context=context)
xml_id = self.find_subtype_xml_id(cr, uid, ids, name="closed", context=context)
self.message_post(cr, uid, [id], body=msg, subtype_xml_id=xml_id, context=context)
return True
def case_cancel_send_note(self, cr, uid, ids, context=None):
for id in ids:
msg = _('%s has been <b>cancelled</b>.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context))
xml_id = self.find_xml_id(cr, uid, ids, name="cancelled", context=context)
xml_id = self.find_subtype_xml_id(cr, uid, ids, name="cancel", context=context)
self.message_post(cr, uid, [id], body=msg, subtype_xml_id=xml_id, context=context)
return True

View File

@ -8,7 +8,7 @@
-
I have add the sub_type name comment with default true
-
!record {model: mail.message.subtype, id: mail.mail_subtype_comment }:
!record {model: mail.message.subtype, id: mail.mt_comment }:
name: comment
res_model: crm.lead
-

View File

@ -13,7 +13,7 @@
<field eval="'()'" name="args"/>
</record>
<record id="mail_subtype_comment" model="mail.message.subtype">
<record id="mt_comment" model="mail.message.subtype">
<field name="name">comment</field>
</record>
</data>

View File

@ -562,8 +562,8 @@ class mail_thread(osv.AbstractModel):
"now deprecated res.log.")
self.message_post(cr, uid, [id], message, context=context)
def message_post(self, cr, uid, thread_id, body='', subject=False,
type='notification', parent_id=False, attachments=None, subtype_xml_id='mail_subtype_comment', context=None, **kwargs):
def message_post(self, cr, uid, thread_id, body='', subject=False, type='notification',
subtype_xml_id=None, parent_id=False, attachments=None, context=None, **kwargs):
""" Post a new message in an existing thread, returning the new
mail.message ID. Extra keyword arguments will be used as default
column values for the new mail.message record.

View File

@ -702,7 +702,7 @@ class test_mail(TestMailMockups):
_mail_bodyalt2 = 'Pigs rules\nAdmin\n'
filter_subtype_id = self.mail_message_subtype.search(cr, uid, [('default','=',True)])
# Post comment with body and subject, comment preference
msg_id = self.mail_group.message_post(cr, uid, [self.group_pigs_id], body=_body1, subject=_subject, type='comment',subtype_xml_id='mail_subtype_comment')
msg_id = self.mail_group.message_post(cr, uid, [self.group_pigs_id], body=_body1, subject=_subject, type='comment',subtype_xml_id='mt_comment')
notif_ids = self.mail_notification.search(cr, uid, [('message_id', '=', msg_id)])
self.assertTrue(len(notif_ids) >= 1,"subtype is email and show notification on wall")