[FIX] mail: notifications: email_to now contains reference to 'Followers of Doc Name' when having a related document.
bzr revid: tde@openerp.com-20130403121022-lijarue6r2t7mh3w
This commit is contained in:
@@ -232,7 +232,19 @@ class mail_mail(osv.Model):
|
||||
subject = self.send_get_mail_subject(cr, uid, mail, partner=partner, context=context)
|
||||
reply_to = self.send_get_mail_reply_to(cr, uid, mail, partner=partner, context=context)
|
||||
body_alternative = tools.html2plaintext(body)
|
||||
email_to = ['%s <%s>' % (partner.name, partner.email)] if partner else tools.email_split(mail.email_to)
|
||||
|
||||
# generate email_to, heuristic:
|
||||
# 1. if 'partner' is specified and there is a related document: Followers of 'Doc' <email>
|
||||
# 2. if 'partner' is specified, but no related document: Partner Name <email>
|
||||
# 3; fallback on mail.email_to that we split to have an email addresses list
|
||||
if partner and mail.record_name:
|
||||
sanitized_record_name = re.sub(r'[^\w+.]+', '-', mail.record_name)
|
||||
email_to = [_('"Followers of %s" <%s>') % (sanitized_record_name, partner.email)]
|
||||
elif partner:
|
||||
email_to = ['%s <%s>' % (partner.name, partner.email)]
|
||||
else:
|
||||
email_to = tools.email_split(mail.email_to)
|
||||
|
||||
return {
|
||||
'body': body,
|
||||
'body_alternative': body_alternative,
|
||||
|
||||
@@ -280,7 +280,8 @@ class test_mail(TestMailBase):
|
||||
'message_post: mail.mail notifications should have been auto-deleted!')
|
||||
|
||||
# Test: notifications emails: to a and b, c is email only, r is author
|
||||
test_emailto = ['Administrator <a@a>', 'Bert Tartopoils <b@b>']
|
||||
# test_emailto = ['Administrator <a@a>', 'Bert Tartopoils <b@b>']
|
||||
test_emailto = ['"Followers of -Pigs-" <a@a>', '"Followers of -Pigs-" <b@b>']
|
||||
self.assertEqual(len(sent_emails), 2,
|
||||
'message_post: notification emails wrong number of send emails')
|
||||
self.assertEqual(set([m['email_to'][0] for m in sent_emails]), set(test_emailto),
|
||||
@@ -353,7 +354,8 @@ class test_mail(TestMailBase):
|
||||
self.assertFalse(self.mail_mail.search(cr, uid, [('mail_message_id', '=', msg2_id)]), 'mail.mail notifications should have been auto-deleted!')
|
||||
|
||||
# Test: emails send by server (to a, b, c, d)
|
||||
test_emailto = [u'Administrator <a@a>', u'Bert Tartopoils <b@b>', u'Carine Poilvache <c@c>', u'D\xe9d\xe9 Grosbedon <d@d>']
|
||||
# test_emailto = [u'Administrator <a@a>', u'Bert Tartopoils <b@b>', u'Carine Poilvache <c@c>', u'D\xe9d\xe9 Grosbedon <d@d>']
|
||||
test_emailto = [u'"Followers of Pigs" <a@a>', u'"Followers of Pigs" <b@b>', u'"Followers of Pigs" <c@c>', u'"Followers of Pigs" <d@d>']
|
||||
# self.assertEqual(len(sent_emails), 3, 'sent_email number of sent emails incorrect')
|
||||
for sent_email in sent_emails:
|
||||
self.assertEqual(sent_email['email_from'], 'Raoul Grosbedon <r@r>',
|
||||
|
||||
Reference in New Issue
Block a user