Email templates
Emails are a very convenient way of sending information to other users or third parties. Odoo has a nice way of providing templates for emails with placeholders that will get filled in with information from the record to which the email is attached when the message is posted. Such templates can be used when manually sending an email, or when a message is sent automatically for instance through a server action.
In this recipe, we will define a mail template to notify a user of the library that they forgot to bring back some documents.
Getting ready
This recipe builds on models introduced in the Write a wizard to guide the user recipe from Chapter 9, Advanced Server-Side Development Techniques, and the Extending the business logic defined in a Model recipe from Chapter 6, Basic Server-Side Development. It also uses the library.book
model from Chapter 4, Creating Odoo Addon Modules.
Here's a rapid and simplified definition of the models we will use in this recipe:
from odoo import...