[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) <pydu@odoo.com> Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user