diff --git a/addons/mail/mail_mail.py b/addons/mail/mail_mail.py index 6219ace864f..1ca3255fd84 100644 --- a/addons/mail/mail_mail.py +++ b/addons/mail/mail_mail.py @@ -202,24 +202,26 @@ class mail_mail(osv.Model): # TDE FIXME BEFORE MERGE: not sure the late change is interesting if mail.reply_to: return mail.reply_to - document_name = '' email_reply_to = False + + # if model and res_id: try to use ``message_get_reply_to`` that returns the document alias if mail.model and mail.res_id and hasattr(self.pool.get(mail.model), 'message_get_reply_to'): email_reply_to = self.pool.get(mail.model).message_get_reply_to(cr, uid, [mail.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 mail.email_from: + match = re.search(r'([^\s,<@]+@[^>\s,]+)', mail.email_from) # TDE TODO: simplify multiple same regex + if match: + email_reply_to = match.group(1) - if not email_reply_to: - if mail.email_from: - match = re.search(r'([^\s,<@]+@[^>\s,]+)', mail.email_from) # TDE TODO: simplify multiple same regex - if match: - email_reply_to = match.group(1) - + # format 'Document name ' if email_reply_to: + document_name = '' if mail.model and mail.res_id: document_name = self.pool.get(mail.model).name_get(cr, SUPERUSER_ID, [mail.res_id], context=context)[0] if document_name: - return 'Followers of %s <%s>' % (document_name[1], email_reply_to) - else: - return email_reply_to + email_reply_to = 'Followers of %s <%s>' % (document_name[1], email_reply_to) + + return email_reply_to def send_get_email_dict(self, cr, uid, mail, partner=None, context=None): """ Return a dictionary for specific email values, depending on a