From b245b8cb6f485bfb379a28c4a5815995e5ea10bb Mon Sep 17 00:00:00 2001 From: Pierre-Yves Dufays Date: Tue, 21 Mar 2023 14:43:52 +0000 Subject: [PATCH] [FIX] mail: fix error while previewing a template without record To reproduce the problem: - Install project - Remove all tasks - Go to settings -> Technical -> Email Templates - Select the template "Project: Task Rating Request" - Click on Preview Without the fix, a stack trace is displayed. With the fix, the preview is displayed with the message "No record for this model" for the field "Test record". Technical note: the error happens because error_msg was not assigned in the compute method of that field when the reference to the record is missing or incomplete. Task-3196081 closes odoo/odoo#116431 X-original-commit: 1f296539210a07e0b1aed0d9d3cd736c5cb33375 Signed-off-by: Dufays Pierre-Yves (pydu) Signed-off-by: Thibault Delavallee (tde) --- addons/mail/wizard/mail_template_preview.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/mail/wizard/mail_template_preview.py b/addons/mail/wizard/mail_template_preview.py index 42f49ff8c84..68ca33421cc 100644 --- a/addons/mail/wizard/mail_template_preview.py +++ b/addons/mail/wizard/mail_template_preview.py @@ -74,6 +74,7 @@ class MailTemplatePreview(models.TransientModel): mail_template = self.mail_template_id.with_context(lang=self.lang) if not self.resource_ref or not self.resource_ref.id: self._set_mail_attributes() + self.error_msg = False else: try: mail_values = mail_template.with_context(template_preview_lang=self.lang)._generate_template(