Files
odoo_source/addons/test_mail/tests/test_mail_template_preview.py
T
Stéphane Debauche aed52f3e0a [IMP] mail: correctly support scheduled_date from template when sending emails
Purpose of this commit is to correctly generate and support scheduled date
defined on template when using ``send_mail`` tool that send emails directly
from a MailTemplate.

It uses the parsing tool method defined on mail.mail in order to have a
datetime localized in UTC then set timezone agnostic as expected by the
ORM.

Task-2826699 (Mail: use datetime for scheduled_date mail field instead of char)

Part-of: odoo/odoo#95623
2022-08-25 19:57:16 +02:00

27 lines
1006 B
Python

# -*- coding: utf-8 -*-
# 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
@tagged('mail_template', 'multi_lang')
class TestMailTemplateTools(TestMailTemplateCommon):
def test_mail_template_preview_force_lang(self):
test_record = self.env['mail.test.lang'].browse(self.test_record.ids)
test_record.write({
'lang': 'es_ES',
})
test_template = self.env['mail.template'].browse(self.test_template.ids)
preview = self.env['mail.template.preview'].create({
'mail_template_id': test_template.id,
'resource_ref': test_record,
'lang': 'es_ES',
})
self.assertEqual(preview.body_html, '<p>SpanishBody for %s</p>' % test_record.name)
preview.write({'lang': 'en_US'})
self.assertEqual(preview.body_html, '<p>EnglishBody for %s</p>' % test_record.name)