[FIX] mail: set body on mail.message on event registration confirmation
Steps: - Go to any event with tickets and using the ticket confirmation template, sending 'after new confirmation'. - Confirm a new attendee. - An email is sent but the chatter only shows the attachment and the subject, with no body. Issue: Chatter should show full content of the email. Reason: Above 16.2+ the 'body' is not implicitely set when genrating the template in ``mail_template.send_mail()``. As discussed with RETH, when requesting the 'body_html' for a template, setting the 'body' solves the problem. opw-3562438 closes odoo/odoo#151930 X-original-commit: 0a3d4b10a7c81d05d9bf6864b0b9a2f48f09b2a0 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
committed by
Maruan Aguerdouh (magm)
parent
844b512077
commit
a3befcc5a9
@@ -652,6 +652,8 @@ class MailTemplate(models.Model):
|
||||
)
|
||||
|
||||
values['body_html'] = self.env['mail.render.mixin']._replace_local_links(body)
|
||||
if 'body_html' in values:
|
||||
values['body'] = values['body_html']
|
||||
|
||||
mail = self.env['mail.mail'].sudo().create(values)
|
||||
|
||||
|
||||
@@ -105,6 +105,16 @@ class TestMailTemplate(TestMailTemplateCommon):
|
||||
self.assertFalse(mail.scheduled_date)
|
||||
self.assertEqual(mail.state, 'outgoing')
|
||||
|
||||
@mute_logger('odoo.addons.mail.models.mail_mail')
|
||||
def test_template_send_mail_body(self):
|
||||
""" Test that the body and body_html is set correctly in 'mail.mail'
|
||||
when sending an email from mail.template """
|
||||
mail_id = self.test_template.send_mail(self.test_record.id)
|
||||
mail = self.env['mail.mail'].sudo().browse(mail_id)
|
||||
body_result = '<p>EnglishBody for %s</p>' % self.test_record.name
|
||||
|
||||
self.assertEqual(mail.body_html, body_result)
|
||||
self.assertEqual(mail.body, body_result)
|
||||
|
||||
@tagged('mail_template', 'multi_lang')
|
||||
class TestMailTemplateLanguages(TestMailTemplateCommon):
|
||||
|
||||
Reference in New Issue
Block a user