Skip to Content
Menu
This question has been flagged
2 Replies
3257 Views

Hello, I have a similar problem with the purchase module, after confirming a purchase order if I want to send by email, I get this error, I have not made modifications on the module or translations.

Could help me see what the error is?


odoo.addons.mail.models.mail_template: Failed to load template u'\n<p style="margin:0px 0px 9px 0px;">Hola ${object.partner_id.name} \n% if object.partner_id.parent_id:\n    (<i>${object.partner_id.parent_id.name}</i>)\n% endif\n,</p>\n<p style="margin:0px 0px 9px 0px;">\nAdjunto le remito la <strong style="font-weight:bold;">${object.state in (\'draft\', \'sent\') and \'solicitud de presupuesto\' or \'confirmaci\xf3n de pedido de compra} ${object.name}</strong>\n% if object.partner_ref:\n    con su referencia: ${object.partner_ref}\n% endif\n% if object.origin:\n    (referencia de pedido: ${object.origin})\n% endif\nTotal del pedido <strong style="font-weight:bold;">${object.amount_total} ${object.currency_id.name}</strong>\nde ${object.company_id.name}.\n</p>\n\n<p style="margin:0px 0px 9px 0px;">Si tiene alguna duda, puede responder este email.</p>\n<p style="margin:0px 0px 9px 0px;">Gracias,</p>\n'
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/odoo/addons/mail/models/mail_template.py", line 374, in render_template
    template = mako_env.from_string(tools.ustr(template_txt))
  File "/usr/lib/python2.7/site-packages/jinja2/environment.py", line 841, in from_string
    return cls.from_code(self, self.compile(source), globals, None)
  File "/usr/lib/python2.7/site-packages/jinja2/environment.py", line 554, in compile
    self.handle_exception(exc_info, source_hint=source)
  File "/usr/lib/python2.7/site-packages/jinja2/environment.py", line 742, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "<unknown>", line 8, in template
TemplateSyntaxError: unexpected char u"'" at 326


I think it is a bug of Odoo, because I made a new configuration, only installing the module and sending the order and confirming generates the error. I'm using odoo 10

Avatar
Discard
Best Answer

make sure your code in field body_html lies in <![CDATA[]] between this attribute

Avatar
Discard
Author Best Answer

this is the structure of the template in purchase -> data -> mail_template_data.xml of the base of Odoo.


<record id="email_template_edi_purchase_done" model="mail.template">
<field name="name">Purchase Order - Send by Email</field>
<field name="email_from">${(object.create_uid.email and '%s &lt;%s&gt;' % (object.create_uid.name, object.create_uid.email) or '')|safe}</field>
<field name="subject">${object.company_id.name} Order (Ref ${object.name or 'n/a' })</field>
<field name="partner_to">${object.partner_id.id}</field>
<field name="model_id" ref="purchase.model_purchase_order"/>
<field name="auto_delete" eval="True"/>
<field name="report_template" ref="action_report_purchase_order"/>
<field name="report_name">PO_${(object.name or '').replace('/','_')}</field>
<field name="lang">${object.partner_id.lang}</field>
<field name="body_html"><![CDATA[
<p>Dear ${object.partner_id.name}
% if object.partner_id.parent_id:
(<i>${object.partner_id.parent_id.name}</i>)
% endif
,</p>
<p>
Please find in attachment a <strong>${object.state in ('draft', 'sent') and 'request for quotation' or 'purchase order confirmation'} ${object.name}</strong>
% if object.partner_ref:
with reference: ${object.partner_ref}
% endif
% if object.origin:
(RFQ origin: ${object.origin})
% endif
amounting <strong>${object.amount_total} ${object.currency_id.name}</strong>
from ${object.company_id.name}.
</p>

<p>You can reply to this email if you have any questions.</p>
<p>Thank you,</p>
]]></field>
</record>

Avatar
Discard