[FIX] mail: show correctly qweb error

Before this commit it is impossible to find the qweb error when you preview an email template.

closes odoo/odoo#139668

X-original-commit: 1f373de5f218a1f43015f4f80e60d1da0188d6b5
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
Florent de Labarre
2023-10-25 19:37:25 +00:00
committed by Thibault Delavallée
parent 67d32fff44
commit 96e3f27424
2 changed files with 5 additions and 3 deletions
+4 -2
View File
@@ -5,6 +5,7 @@ import babel
import copy
import logging
import re
import traceback
from lxml import html
from markupsafe import Markup
@@ -325,8 +326,9 @@ class MailRenderMixin(models.AbstractModel):
) from e
_logger.info("Failed to render template: %s", template_src, exc_info=True)
raise UserError(
_("Failed to render QWeb template: %(template_src)s)",
template_src=template_src)
_("Failed to render QWeb template: %(template_src)s\n\n%(template_traceback)s)",
template_src=template_src,
template_traceback=traceback.format_exc())
) from e
results[record.id] = render_result
@@ -11,7 +11,7 @@
<h3>Preview of <field name="mail_template_id" readonly="1" nolabel="1" options="{'no_open': True}"/></h3>
</div>
<div class="alert alert-danger" role="alert" invisible="not error_msg">
<field name="error_msg" />
<field name="error_msg" widget="text"/>
</div>
<field name="no_record" invisible="1"/>