Error :
Echec de rendu du modèle <Template memory:80e1810> utilisant les valeurs {'format_date': <function MailTemplate.render_template.<locals>.<lambda> at 0x080314B0>, 'format_tz': <function MailTemplate.render_template.<locals>.<lambda> at 0x08031DB0>, 'format_amount': <function MailTemplate.render_template.<locals>.<lambda> at 0x080318A0>, 'user': res.users(1,), 'ctx': {'lang': 'fr_FR', 'tz': False, 'uid': 1, 'params': {'action': 387}, 'safe': False}, 'object': profile.user(83,)}
Template :
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<record id="email_template_rec" model="mail.template">
<field name="name">Template Profile</field>
<field name="model_id" ref="user_profil.model_profile_user"/>
<field name="email_from">${object.current_user.email}</field>
<field name="email_to">${object.current_emp.current_coach.work_email}</field>
<field name="lang">${object.current_user.lang}</field>
<field name="subject">Invitation</field>
<field name="body_html"><![CDATA[
<p><strong>Dear Coordinator(s)</strong></p>
<p><strong>Department: --department--</strong></p>
<p>Please do the following activities in LMS.</p>]]>
</field>
</record>
</data>
</odoo>
Function:@api.multi
def send_mail(self):
self.ensure_one()
template_id = self.env.ref('user_profil.email_template_rec')
template_id.send_mail(self.ids[0], force_send=True)
ctx = {
'default_model': 'profile.user',
'default_res_id': self.id,
'default_use_template': bool(template_id),
'default_template_id': template_id,
'default_composition_mode': 'comment',
}
return {
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'mail.compose.message',
'target': 'new',
'context': ctx,
}
try this: http://learnopenerp.blogspot.com/2017/08/odoo-how-to-send-email-on-button-click.html