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

Hello,
I'am using Odoo 10, an I want to send mails to customers, but when I choose the email template I get this warning:

Failed to render template <Template memory:7f6ef3136b50> using values {'format_tz': <function <lambda> at 0x7f6ef3cdbd70>, 'format_date': <function <lambda> at 0x7f6ef3cdb938>, 'ctx': {u'lang': u'en_US', u'tz': False, u'uid': 1, u'active_model': u'account.invoice', u'params': {u'action': 251}, u'search_disable_custom_filters': True, u'active_ids': [2], 'tpl_partners_only': True, u'active_id': 2}, 'user': res.users(1,), 'object': None}

Despite that I send mails when I click in the button Validate.
This is my python code:

class AccountInvoiceBymail(models.TransientModel):
_name = 'account.voucher.bymail'
_inherit = 'mail.compose.message'
@api.model
    def invoice_selection(self):
return self.env['account.invoice'].browse(self._context.get('active_ids'))
@api.multi
    def send_mail_invoice(self):
for invoice in self.invoice_ids:
if (invoice.email and invoice.state != 'draft'):
template = self.template_id template.send_mail(invoice.id, force_send=True) invoice.write({'mail_sent': True})
invoice_ids = fields.Many2many('account.invoice', default=invoice_selection)


And this is my xml code:

<field name="template_id" domain="[('model','=','account.invoice')]" widget="selection"/>


Knowing that it works perfectly under odoo 8.
Thank you.
Best regards

Avatar
Discard

what error does it shows in log file ?

Best Answer

HI, please check your Template code, must have some errors there. Possibly not on your script. Maybe you are fetching wrong values on email template with the object of account.invoice.

Thanks

Avatar
Discard
Author Best Answer

2017-03-14 14:39:10,826 30297 INFO db_cloud odoo.addons.mail.models.mail_template: Failed to render template <Template memory:7f51fc1c7f90> using values {'format_tz': <function <lambda> at 0x7f51fd95cb90>, 'format_date': <function <lambda> at 0x7f51fd95c230>, 'ctx': {u'lang': u'en_US', u'tz': False, u'uid': 1, u'active_model': u'account.invoice', u'params': {u'action': 251}, u'search_disable_custom_filters': True, u'active_ids': [1], 'tpl_partners_only': True, u'active_id': 1}, 'user': res.users(1,), 'object': None}Traceback (most recent call last):
  File "/home/odoo10/odoo-dev/odoo/addons/mail/models/mail_template.py", line 376, in render_template    render_result = template.render(variables)  File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 989, in render    return self.environment.handle_exception(exc_info, True)  File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 754, in handle_exception    reraise(exc_type, exc_value, tb)  File "<template>", line 1, in top-level template code  File "/usr/lib/python2.7/dist-packages/jinja2/sandbox.py", line 329, in getattr    value = getattr(obj, attribute)UndefinedError: 'None' has no attribute 'partner_id'

Avatar
Discard