Tutorial: Create Email Template
Learn how to create and send email templates in Odoo
Email
Template
Tutorial
Overview
This tutorial module teaches you how to create email templates in Odoo. Learn to design professional email templates, trigger them from Python code, and customize email content dynamically.
What You'll Learn
- How to create email templates using XML data files
- Dynamic content with Jinja2 placeholders (${object.field})
- Loading templates by XML ID in Python
- Opening the email composer with pre-filled template
- Sending emails directly without user interaction
Contains
- New email template "Contact: Happy Birthday"
- New button "Send Birthday Email" on contact form
- New field "birthdate" on res.partner model
- Fully documented Python and XML code
Key Code Examples
Email Template XML
<record id="email_template_birthday" model="mail.template">
<field name="subject">Happy Birthday, ${object.name}!</field>
<field name="body_html">...</field>
</record>
Loading Template in Python
template = self.env.ref('module.template_id')
template.send_mail(record.id, force_send=True)
Technical Information
Tutorial: Create Email Template
Learn how to create and send email templates in Odoo
Email
Template
Tutorial
Overview
This tutorial module teaches you how to create email templates in Odoo. Learn to design professional email templates, trigger them from Python code, and customize email content dynamically.
What You'll Learn
- How to create email templates using XML data files
- Dynamic content with Jinja2 placeholders (${object.field})
- Loading templates by XML ID in Python
- Opening the email composer with pre-filled template
- Sending emails directly without user interaction
Contains
- New email template "Contact: Happy Birthday"
- New button "Send Birthday Email" on contact form
- New field "birthdate" on res.partner model
- Fully documented Python and XML code
Key Code Examples
Email Template XML
<record id="email_template_birthday" model="mail.template">
<field name="subject">Happy Birthday, ${object.name}!</field>
<field name="body_html">...</field>
</record>
Loading Template in Python
template = self.env.ref('module.template_id')
template.send_mail(record.id, force_send=True)
Technical Information
Version: 19.0.1.0.0
Dependencies: base, mail, contacts
License: OPL-1
Please log in to comment on this module