Skip to content

Commit

Permalink
Merge pull request #162 from gisce/59452_imp_render_error_wizard_prev…
Browse files Browse the repository at this point in the history
…iew_mail

Renderizar error en HTML cuando falla la previsualización del cuerpo del mail desde el asistente de previsualizar correo
  • Loading branch information
lcbautista authored Jul 16, 2024
2 parents 243bb62 + 490e6e0 commit 75fed03
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions wizard/wizard_poweremail_preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import sys
import traceback
from mako.exceptions import html_error_template

from osv import osv, fields
from ..poweremail_template import get_value
Expand Down Expand Up @@ -95,9 +96,11 @@ def action_generate_static_mail(self, cr, uid, ids, context=None):
field_value = getattr(template, "def_{}".format(field))
vals[field] = get_value(cr, uid, record_id, field_value, template, ctx)
except Exception as e:
import traceback
tb = traceback.format_tb(sys.exc_info()[2])
vals[field] = ''.join(tb)
if field == 'body_text':
vals[field] = html_error_template().render()
else:
tb = traceback.format_tb(sys.exc_info()[2])
vals[field] = '{}\n{}'.format(e.message, ''.join(tb))
vals['state'] = 'error'

self.write(cr, uid, ids, vals, context=context)
Expand Down

0 comments on commit 75fed03

Please sign in to comment.