[FIX] mail.compose.message: fixed reply_to from template in mass mailing.

bzr revid: tde@openerp.com-20130606142814-jyw76nhaeivotu6k
This commit is contained in:
Thibault Delavallée 2013-06-06 16:28:14 +02:00
parent 05d463a0e2
commit a1e942c0de
3 changed files with 10 additions and 7 deletions

View File

@ -66,6 +66,9 @@ class mail_mail(osv.Model):
}
def _get_default_from(self, cr, uid, context=None):
""" Kept for compatibility
TDE TODO: remove me in 8.0
"""
return self.pool['mail.message']._get_default_from(cr, uid, context=context)
_defaults = {
@ -85,14 +88,15 @@ class mail_mail(osv.Model):
"""
if values.get('reply_to'):
return values.get('reply_to')
email_reply_to = False
# model, res_id: comes from values OR related message
# email_reply_to, model, res_id: comes from values OR related message
email_reply_to = False
model = values.get('model')
res_id = values.get('res_id')
email_from = values.get('email_from')
if values.get('mail_message_id') and (not model or not res_id):
message = self.pool.get('mail.message').browse(cr, uid, values.get('mail_message_id'), context=context)
email_reply_to = message.reply_to
if not model:
model = message.model
if not res_id:
@ -101,7 +105,7 @@ class mail_mail(osv.Model):
email_from = message.email_from
# if model and res_id: try to use ``message_get_reply_to`` that returns the document alias
if model and res_id and hasattr(self.pool[model], 'message_get_reply_to'):
if not email_reply_to and model and res_id and hasattr(self.pool[model], 'message_get_reply_to'):
email_reply_to = self.pool[model].message_get_reply_to(cr, uid, [res_id], context=context)[0]
# no alias reply_to -> reply_to will be the email_from, only the email part
if not email_reply_to and email_from:

View File

@ -352,9 +352,6 @@ class mail_message(osv.Model):
else:
partner_ids = [partner_tree[partner.id] for partner in message.partner_ids
if partner.id in partner_tree]
# for partner in message.notified_partner_ids:
# if partner.id in partner_tree:
# partner_ids.append(partner_tree[partner.id])
attachment_ids = []
for attachment in message.attachment_ids:
if attachment.id in attachments_tree:

View File

@ -259,13 +259,15 @@ class mail_compose_message(osv.TransientModel):
new_attach_id = ir_attachment_obj.copy(cr, uid, attach_id, {'res_model': self._name, 'res_id': wizard.id}, context=context)
attachment_ids.append(new_attach_id)
post_values['attachment_ids'] = attachment_ids
post_values.update(email_dict)
# email_from: mass mailing only can specify another email_from
if email_dict.get('email_from'):
post_values['email_from'] = email_dict.pop('email_from')
# replies redirection: mass mailing only
if not wizard.same_thread:
post_values['reply_to'] = email_dict.pop('reply_to')
else:
email_dict.pop('reply_to')
post_values.update(email_dict)
# clean the context (hint: mass mailing sets some default values that
# could be wrongly interpreted by mail_mail)
context.pop('default_email_to', None)