[IMP] test_mail: add template preview test about recipients
Add a test that check recipients displayed in the template preview. This test has been added following the fix that solves the template "partner_to" not displayed in the preview. Task-3196081 X-original-commit: 86a492275e56217a5edd57d99a0db7576aa91377 Part-of: odoo/odoo#116431
This commit is contained in:
@@ -2,11 +2,23 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo.addons.test_mail.tests.test_mail_template import TestMailTemplateCommon
|
||||
from odoo.tests import tagged
|
||||
|
||||
from odoo.tests import tagged, users
|
||||
from odoo.tests.common import Form
|
||||
|
||||
@tagged('mail_template', 'multi_lang')
|
||||
class TestMailTemplateTools(TestMailTemplateCommon):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.test_template_preview = cls.env['mail.template.preview'].create({
|
||||
'mail_template_id': cls.test_template.id,
|
||||
})
|
||||
|
||||
def test_initial_values(self):
|
||||
self.assertTrue(self.test_template.email_to)
|
||||
self.assertTrue(self.test_template.email_cc)
|
||||
self.assertEqual(len(self.test_template.partner_to.split(',')), 2)
|
||||
self.assertTrue(self.test_record.email_from)
|
||||
|
||||
def test_mail_template_preview_force_lang(self):
|
||||
test_record = self.env['mail.test.lang'].browse(self.test_record.ids)
|
||||
@@ -24,3 +36,23 @@ class TestMailTemplateTools(TestMailTemplateCommon):
|
||||
|
||||
preview.write({'lang': 'en_US'})
|
||||
self.assertEqual(preview.body_html, '<p>EnglishBody for %s</p>' % test_record.name)
|
||||
|
||||
@users('employee')
|
||||
def test_mail_template_preview_recipients(self):
|
||||
form = Form(self.test_template_preview)
|
||||
form.resource_ref = self.test_record
|
||||
|
||||
self.assertEqual(form.email_to, self.test_template.email_to)
|
||||
self.assertEqual(form.email_cc, self.test_template.email_cc)
|
||||
self.assertEqual(set(record.id for record in form.partner_ids),
|
||||
{int(pid) for pid in self.test_template.partner_to.split(',') if pid})
|
||||
|
||||
@users('employee')
|
||||
def test_mail_template_preview_recipients_use_default_to(self):
|
||||
self.test_template.use_default_to = True
|
||||
form = Form(self.test_template_preview)
|
||||
form.resource_ref = self.test_record
|
||||
|
||||
self.assertEqual(form.email_to, self.test_record.email_from)
|
||||
self.assertFalse(form.email_cc)
|
||||
self.assertFalse(form.partner_ids)
|
||||
|
||||
Reference in New Issue
Block a user