Hello,
I define new process that will send the email automatically without through the wizard.
I create new template (adapt from existing one), but when i send it, i check the email and the email i got is not supposed to be, the email is weird.
from the server is trace the log, they look like this:
MissingError: ('MissingError', 'One of the documents you are trying to access has been deleted, please try again after refreshing.')
2015-02-17 05:44:08,316 1100 ERROR tes06 openerp.addons.email_template.email_template: Failed to render template <Template memory:7f76f8117bd0> using values {'format_tz': <function <lambda> at 0x7f76e8b8bc08>, 'ctx': {'default_use_template': True, 'lang': None, 'default_composition_mode': 'comment', 'default_template_id': 31, 'default_res_id': 56, 'mark_so_as_sent': True, 'default_model': 'sale.order', 'tpl_partners_only': True}, 'user': res.users(1,), 'object': account.invoice(56,)}
the email i got, is like this:
Hello ${object.partner_id.name},
We want to say thank you for your trusted to us.
Here the information about your sale order,
REFERENCES
Invoice number: ${object.number}
Invoice total: ${object.amount_total} ${object.currency_id.name}
Invoice date: ${object.date_invoice}
% if object.origin: Order reference: ${object.origin}
% endif % if object.user_id: Your contact: ${object.user_id.name} % endif
here my code:
@api.one
def action_mail_send(self):
mail_compose = self.env['mail.compose.message']
# get the template
template_id = self.so_paid_email_template()
# modify the context
ctx = dict()
ctx.update({ 'default_model': 'sale.order', 'default_res_id': self.ids[0], 'default_use_template': bool(template_id), 'default_template_id': template_id.id, 'default_composition_mode': 'comment', 'mark_so_as_sent': True, })
# compose message
new_message = mail_compose.with_context(ctx).create({ 'partner_ids': self.partner_id.email, 'body': template_id.body_html, })
# send
new_message.send_mail()
return True
Thank You,