Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
9982 Vizualizări

Hi,

I'm trying to send an email based on a template, but I'm getting errors, it fails to render whatever I write in the template:

 

2014-10-08 01:40:49,924 4788 ERROR pau_test openerp.addons.email_template.email_template: failed to render mako template value u'Whatever'
Traceback (most recent call last):
  File "E:\13_workspace\openerp7BDT\openerp\addons\email_template\email_template.py", line 99, in render_template
    result = mako_template_env.from_string(template).render(variables)
NameError: global name 'mako_template_env' is not defined
2014-10-08 01:40:49,924 4788 ERROR pau_test openerp.addons.email_template.email_template: failed to render mako template value u'\n<div style="font-family: \'Lucida Grande\', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: rgb(255, 255, 255); ">\nHola que tal    \n    </div>\n            '
Traceback (most recent call last):
  File "E:\13_workspace\openerp7BDT\openerp\addons\email_template\email_template.py", line 99, in render_template
    result = mako_template_env.from_string(template).render(variables)
NameError: global name 'mako_template_env' is not defined
2014-10-08 01:40:49,924 4788 ERROR pau_test openerp.addons.email_template.email_template: failed to render mako template value u"${object.user_id.email or ''}"
Traceback (most recent call last):
  File "E:\13_workspace\openerp7BDT\openerp\addons\email_template\email_template.py", line 99, in render_template
    result = mako_template_env.from_string(template).render(variables)
NameError: global name 'mako_template_env' is not defined
2014-10-08 01:40:49,924 4788 ERROR pau_test openerp.addons.email_template.email_template: failed to render mako template value u'false.mail@yahoo.es'
Traceback (most recent call last):
  File "E:\13_workspace\openerp7BDT\openerp\addons\email_template\email_template.py", line 99, in render_template
    result = mako_template_env.from_string(template).render(variables)
NameError: global name 'mako_template_env' is not defined
2014-10-08 01:40:49,924 4788 ERROR pau_test openerp.addons.email_template.email_template: failed to render mako template value u'any.mail@yahoo.es'
Traceback (most recent call last):
  File "E:\13_workspace\openerp7BDT\openerp\addons\email_template\email_template.py", line 99, in render_template
    result = mako_template_env.from_string(template).render(variables)
NameError: global name 'mako_template_env' is not defined

Here's the function used in python:

    def action_button_quot_to_customer(self, cr, uid, ids, context=None):
        self.write(cr, uid, ids, {'state': '1'})
        assert len(ids) == 1, 'This option should only be used for a single id at a time.'
        ir_model_data = self.pool.get('ir.model.data')
        try:
            template_id = ir_model_data.get_object_reference(cr, uid, 'digitexx_bdt', 'email_template_quotation')[1]
        except ValueError:
            template_id = False
        try:
            compose_form_id = ir_model_data.get_object_reference(cr, uid, 'mail', 'email_compose_message_wizard_form')[1]
        except ValueError:
            compose_form_id = False 
        
        ctx = dict(context)
        ctx.update({
            'default_model': 'bdt.quotation',
            'default_res_id': ids[0],
            'default_use_template': bool(template_id),
            'default_template_id': template_id,
            'default_composition_mode': 'comment',
            'mark_so_as_sent': True
        })
        return {
            'type': 'ir.actions.act_window',
            'view_type': 'form',
            'view_mode': 'form',
            'res_model': 'mail.compose.message',
            'views': [(compose_form_id, 'form')],
            'view_id': compose_form_id,
            'target': 'new',
            'context': ctx,
        }

And here's the template:

<record id="email_template_quotation" model="email.template">
            <field name="name">Quotation - Send to Customer</field>
            <field name="email_from">${object.user_id.email or ''}</field>
            <field name="subject">Whatever</field>
            <field name="email_to">false.mail@yahoo.es</field>
            <field name="model_id" ref="digitexx_bdt.model_bdt_quotation"/>
            <field name="auto_delete" eval="True"/>
            <field name="body_html"><![CDATA[
<div style="font-family: 'Lucida Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: rgb(255, 255, 255); ">
Hola que tal    
    </div>
            ]]></field>
        </record>

Imagine profil
Abandonează
Autor Cel mai bun răspuns

It was an error with Jinja2. I reinstalled it and now it works.

Imagine profil
Abandonează
Cel mai bun răspuns

How did you reinstall jinja2, can you share the steps.

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
2
ian. 24
4302
1
mar. 21
9541
0
ian. 19
7123
0
mar. 15
3621
1
mar. 15
6875