This is related to revision
71f188082f
This is nice to have a meaningful explanation
for the user to understand why his mail is not sent,
this is better to not interrupt the mail queue when doing so.
Because of the above revision,
when the mail queue iterated on a mail failing because
of an ASCII encoding issue,
the mail queue was interrupted,
and on the next cron call it failed again and again
on the same mail, therefore leading to the mail queue
to never be processed.
Fixes #27804
52 lines
2.2 KiB
Python
52 lines
2.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
import itertools
|
|
|
|
from odoo.addons.test_mail.tests import common as mail_common
|
|
from odoo.tests import common
|
|
from odoo.tools import mute_logger
|
|
from odoo.addons.base.models.ir_mail_server import MailDeliveryException
|
|
|
|
|
|
class TestMail(common.SavepointCase, mail_common.MockEmails):
|
|
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
super(TestMail, cls).setUpClass()
|
|
|
|
cls.user_employee = cls.env['res.users'].with_context(mail_common.BaseFunctionalTest._test_context).create({
|
|
'name': 'Ernest Employee',
|
|
'login': 'ernest',
|
|
'email': 'e.e@example.com',
|
|
'signature': '--\nErnest',
|
|
'notification_type': 'email',
|
|
'groups_id': [(6, 0, [cls.env.ref('base.group_user').id])]
|
|
})
|
|
|
|
@mute_logger('odoo.addons.mail.models.mail_mail')
|
|
def test_mail_message_notify_from_mail_mail(self):
|
|
# Due ot post-commit hooks, store send emails in every step
|
|
self.email_to_list = []
|
|
mail = self.env['mail.mail'].create({
|
|
'body_html': '<p>Test</p>',
|
|
'email_to': 'test@example.com',
|
|
'partner_ids': [(4, self.user_employee.partner_id.id)]
|
|
})
|
|
self.email_to_list.extend(itertools.chain.from_iterable(sent_email['email_to'] for sent_email in self._mails if sent_email.get('email_to')))
|
|
self.assertNotIn(u'Ernest Employee <e.e@example.com>', self.email_to_list)
|
|
mail.send()
|
|
self.email_to_list.extend(itertools.chain.from_iterable(sent_email['email_to'] for sent_email in self._mails if sent_email.get('email_to')))
|
|
self.assertNotIn(u'Ernest Employee <e.e@example.com>', self.email_to_list)
|
|
self.assertIn(u'test@example.com', self.email_to_list)
|
|
|
|
@mute_logger('odoo.addons.mail.models.mail_mail')
|
|
def test_mail_message_values_unicode(self):
|
|
mail = self.env['mail.mail'].create({
|
|
'body_html': '<p>Test</p>',
|
|
'email_to': 'test.😊@example.com',
|
|
'partner_ids': [(4, self.user_employee.partner_id.id)]
|
|
})
|
|
|
|
self.assertRaises(MailDeliveryException, lambda: mail.send(raise_exception=True))
|