[FIX] [IMP] mail: allow to use message_post on models not having message_post method defined.
mail.compose.message wizard and messaage_process now check that the active model has message_post defined. Otherwise using thread_model context key that is better managed in message_post, it is possible to use mail_thread.message_post() with a thread_model and thread_id that should not allow message_post otherwise. Hint: look for backport into 7.0 bzr revid: tde@openerp.com-20130606123230-d7ql14yydzfrlc7h
This commit is contained in:
parent
9c57f6e1cd
commit
a216e70e85
|
@ -730,6 +730,9 @@ class mail_thread(osv.AbstractModel):
|
|||
else:
|
||||
assert thread_id == 0, "Posting a message without model should be with a null res_id, to create a private message."
|
||||
model_pool = self.pool.get('mail.thread')
|
||||
if not hasattr(hasattr, 'message_post'):
|
||||
context['thread_model'] = model
|
||||
model_pool = self.pool['mail.thread']
|
||||
new_msg_id = model_pool.message_post(cr, uid, [thread_id], context=context, subtype='mail.mt_comment', **msg)
|
||||
|
||||
if partner_ids:
|
||||
|
@ -1064,7 +1067,7 @@ class mail_thread(osv.AbstractModel):
|
|||
model = False
|
||||
if thread_id:
|
||||
model = context.get('thread_model', self._name) if self._name == 'mail.thread' else self._name
|
||||
if model != self._name:
|
||||
if model != self._name and hasattr(self.pool[model], 'message_post'):
|
||||
del context['thread_model']
|
||||
return self.pool[model].message_post(cr, uid, thread_id, body=body, subject=subject, type=type, subtype=subtype, parent_id=parent_id, attachments=attachments, context=context, content_subtype=content_subtype, **kwargs)
|
||||
|
||||
|
|
|
@ -234,6 +234,9 @@ class mail_compose_message(osv.TransientModel):
|
|||
for wizard in self.browse(cr, uid, ids, context=context):
|
||||
mass_mail_mode = wizard.composition_mode == 'mass_mail'
|
||||
active_model_pool = self.pool[wizard.model if wizard.model else 'mail.thread']
|
||||
if not hasattr(active_model_pool, 'message_post'):
|
||||
context['thread_model'] = wizard.model
|
||||
active_model_pool = self.pool['mail.thread']
|
||||
|
||||
# wizard works in batch mode: [res_id] or active_ids
|
||||
res_ids = active_ids if mass_mail_mode and wizard.model and active_ids else [wizard.res_id]
|
||||
|
|
Loading…
Reference in New Issue