Purpose of this commit is to add tests for language-based tweaks of email notification layouts and composer usage. Purpose is to assess current behavior before going into some cleaning or refactoring. Notably * check layout content is translated; * check "view document" button is translated; * check action buttons are translated; * check content based on templates is translated; This is currently mainly available through the "lang" context key being correctly set. Partial support of translations when posting based on template is tested (content and model description but not notification layout). Failing support in mass mail mode is tested. Future improvements will be done in order to improve language support. Note that ``MailTemplate.send_mail()`` email sending method language support is tested in ``test_mail_template`` file. Those tests are updated to share a common base with new tests about language setup. Task-2712450 (Mail/Sale: Improve 'Pay Now' notification template) Part-of: odoo/odoo#82167
27 lines
980 B
Python
27 lines
980 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 TestMailTemplate
|
|
from odoo.tests import tagged
|
|
|
|
|
|
@tagged('mail_template')
|
|
class TestMailTemplateTools(TestMailTemplate):
|
|
|
|
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)
|