Skip to content

Commit

Permalink
Merge pull request #167 from gisce/61462_fix_localize_requires_language
Browse files Browse the repository at this point in the history
No se renderizaba el contenido del email si no se encontraba idioma
  • Loading branch information
lcbautista authored Aug 9, 2024
2 parents 1c6ef83 + 84fa7ad commit a06f88e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
16 changes: 16 additions & 0 deletions migrations/5.0.24.9.0/post-0003_update_preview_email_view.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
from oopgrade.oopgrade import load_data_records


def up(cursor, installed_version):
if not installed_version:
return

load_data_records(cursor, 'poweremail', 'wizard/wizard_poweremail_preview.xml', ['poweremail_preview_form'])


def down(cursor, installed_version):
pass


migrate = up
4 changes: 4 additions & 0 deletions poweremail_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,15 @@ def get_value(cursor, user, recid, message=None, template=None, context=None):
}
values.update(extra_render_values)
reply = templ.render_unicode(**values)
if reply == 'False':
reply = False
elif template.template_language == 'django':
templ = DjangoTemplate(message)
env['object'] = object
env['peobject'] = object
reply = templ.render(Context(env))
if reply == 'False':
reply = False
return reply or False
except Exception as e:
if context.get('raise_exception', False):
Expand Down
3 changes: 2 additions & 1 deletion wizard/wizard_poweremail_preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def get_save_to_draft(self, cursor, uid, context=None):
'cc': fields.char('CC', size=250, readonly=True),
'bcc': fields.char('BCC', size=250, readonly=True),
'subject': fields.char('Subject', size=200, readonly=True),
'lang': fields.char('Language', size=6, readonly=True),
'body_text': fields.text('Body', readonly=True),
'body_html': fields.text('Body', readonly=True),
'report': fields.char('Report Name', size=100, readonly=True),
Expand All @@ -75,7 +76,6 @@ def action_generate_static_mail(self, cr, uid, ids, context=None):
if not wizard_values:
return {}

vals = {}
wizard_values = wizard_values[0]
model_name, record_id = wizard_values['model_ref'].split(',')
record_id = int(record_id)
Expand All @@ -88,6 +88,7 @@ def action_generate_static_mail(self, cr, uid, ids, context=None):
ctx.update({'lang': lang})
template = self.pool.get('poweremail.templates').browse(cr, uid, context['active_id'], ctx)

vals = {'lang': str(lang)}
mail_fields = ['to', 'cc', 'bcc', 'subject', 'body_text', 'body_html', 'report']
ctx['raise_exception'] = True
if wizard_values['env']:
Expand Down
3 changes: 2 additions & 1 deletion wizard/wizard_poweremail_preview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
<form string="Power Email Preview">
<field name="state" invisible="1"/>
<field name="model_ref" colspan="4"/>
<field name="to" colspan="4"/>
<field name="to" colspan="2"/>
<field name="cc" colspan="2"/>
<field name="bcc" colspan="2"/>
<field name="lang" colspan="2"/>
<field name="subject" colspan="4"/>
<field name="env" colspan="4" widget="codeeditor" widget_props="{'lang': 'json'}" height="100"/>
<notebook>
Expand Down

0 comments on commit a06f88e

Please sign in to comment.