From 244e4cae0334ee4de718ea4fd9d3399291096824 Mon Sep 17 00:00:00 2001 From: "Anh Thao Pham (pta)" Date: Fri, 14 Jan 2022 09:04:01 +0000 Subject: [PATCH] [FIX] mass_mailing: fix preview prepend when sending test email - Go to Email Marketing and create a new one - Select any template - In Settings tab, set a Preview Text - Send a test The content of the received test email is a text with the html code of the email body. When sending the test email, the body is retrieved with "render_field" method, which does not return a Markup object but a simple string. Then "_prepend_preview" method prepends preview (Markup) to body (str). opw-2686316 closes odoo/odoo#82886 X-original-commit: 71258f5020a0d1c4581cf85df31be3fb3f95562a Signed-off-by: Thibault Delavallee (tde) --- addons/mass_mailing/wizard/mailing_mailing_test.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/mass_mailing/wizard/mailing_mailing_test.py b/addons/mass_mailing/wizard/mailing_mailing_test.py index e2abffe1216..a25edffc5b6 100644 --- a/addons/mass_mailing/wizard/mailing_mailing_test.py +++ b/addons/mass_mailing/wizard/mailing_mailing_test.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. +from markupsafe import Markup + from odoo import _, fields, models, tools @@ -39,7 +41,7 @@ class TestMassMailing(models.TransientModel): # Returns a proper error if there is a syntax error with Qweb body = mailing._render_field('body_html', record.ids, post_process=True)[record.id] preview = mailing._render_field('preview', record.ids, post_process=True)[record.id] - full_body = mailing._prepend_preview(body, preview) + full_body = mailing._prepend_preview(Markup(body), preview) subject = mailing._render_field('subject', record.ids)[record.id] else: full_body = mailing._prepend_preview(mailing.body_html, mailing.preview)