Set Up Automated Emails on SLA Events

In this article, we will explore one of the ways to configure automatic email notifications in Bureaucrat system and in Odoo in general. The configuration will cover the following topics:

  • Setting up Odoo email templates

  • Configuration of automated actions in the Bureaucrat system

We also will partly consider creation of teams and custom conditions in our system.

What we plan to do:

Set up Incident type of request to send emails on SLA events using automated actions.

We have 2 configured SLA Rules: Reaction Time and Resolve Time (see previous article). The task is to set up actions to automatically send emails when SLA reaches its warning and limit.

On the Reaction Time SLA Rule (until request is assigned), an email on the SLA Warning should be sent to all members of the Frontend Team. When the Rosolve Time SLA Rule is active (after request is assigned), an SLA Warning email must be sent to the assigned person.

An email about failed SLA on the Reaction Time Rule, should be sent to the Team leader; and on the Resolve Time Rule, it should be sent to the manager of the assigned person.

Let's quickly review the Frontend Team configuration

Using our Generic Team addon, we previously created the Frontend team. It is a simple team with a team leader and 2 team members.

For more info on how to create a team, read the Documentation.

Configure Event Conditions

We also need to create 2 custom conditions. These conditions will help to determine the active SLA Rule at the present time.

Created conditions will check if the related field "SLA Rule type" is set to Assigned (or Unassigned).

We can create conditions from the Rules -> Generic Conditions menu, or we can do this directly from the action form when we select the event conditions.

SLA Rule type - Assigned:

SLA Rule type - Unassigned:

More info about creating generic conditions you can read in the Documentation.

Setting Up Automated Actions

Open the Incident type of request in the edit mode. Click Actions on the form.

Click Create to create a new action.

First, we will create actions for the Resolve Time SLA Rule.

Automated Action: send email on SLA Warning to the assigned person

This action will activate on the Resolve Time SLA Rule and will send an email to the assigned person.

The configuration will be as follows:

  1. Enter the name of the Action.

  2. This action should send emails on SLA Warning. Select Event: SLA Warning.

  3. Select the Event condition: SLA Rule type - Assigned. This action is configured for the Resolve Time SLA Rule (when request is assigned).

  4. Type of action - Send Email.

  5. On the Send Email tab, we need to select or create an email template for this email. There is no default email templates for our needs, so wee will create a new one.

Odoo Email Templates

Email template allows to specify content of the email, email address of the sender, recipients, copy recipients, preferred response addresses, translation language, outgoing mail server, even schedule send date, etc.

Most all of the template fields may use Jinja2 (Maco compatible) placeholders. They allow to use template language for programming some logic and get values from models and fields.

The template expression should be in curly brackets and it must be preceded by the "$" sign.

Let's create a template with a simple content that will be sent to the assigned person.

In the upper fields, we need to enter the template name: SLA Warning notification (Resolve Time), and specify the type of document this template can be used with. We select Request.

The Content tab configuration

  • Subject

    SLA Warning: ${object.display_name}
    "object" represents the current request
    "object.display_name" - will display the name of request

  • Email text template

    " or ''" - will insert the name of the assigned person ("") or an empty character (''), if there is no assigned user.
    "object.sudo().type_id.display_name" - will display the name of the request type. We use "sudo()" to pass the security restrictions and get the request type name.
    "" - will display the request name. We can use the request name as a link to allow the assigned person to open this request from the mail body. We can do the following:
        - select the text and click the Link icon, or press Ctrl + K.

        - In the URL or Email field, specify the method of the Request model that gets request link.

Now we can make Email Configuration

On this tab, we can specify the sender address. This will be the user company's address.

${( and '"%s" <%s>' % (, or '')|safe}

This line will place user company name and email to the sender field. "|safe" - is a filter to prevent automatic escaping of this value.

Recipient should be the assigned user. We can configure this using either 1) To (Emails) field - there we need to enter the required email address (""), or 2) To (Partners) field - we can specify the partner id in this field ("").

Advanced Settings

On this tab, we can specify the translation language of the email. It should be the language of the assigned user ("object.user_id.lang").

The Dynamic Placeholder Generator tab allows to generate placeholder expression to use in the email template. It can be very helpful. You just need to select the required field / sub-field of the model and specify the default value if necessary.

Now email template is complete and we can save the action.

And here is an example of the set up email, that is sent using our configuration.

Automated Action: send email on SLA Failed to the manager of the assigned person

This action will send emails to the manager of the assigned person in case of SLA fails. It will have the similar configuration, with a few differences.

The Event to trigger the action will be SLA Failed.

The Event Condition will also be the same: SLA Rule type - Assigned.

And we need to create a new email template to send the email to the manager of the assigned user.

In the email template, we need to specify HR related fields. We can use our Bureaucrat HR (user) addon to do this more conveniently.

Bureaucrat HR (user) Addon

Bureaucrat HR (user) is a technical addon. It extends the standard user model by adding additional HR-related fields. These fields are employee_id, hr_job_id, hr_department_id, hr_manager_id, hr_coach_id.

With this addon, we can use hr_manager_id field form the user model to specify the manager of the assigned user.

Now we can set up email template to send emails to the manager in case of SLA failure.

Content tab

  • Subject

    SLA Failed: ${object.display_name}

  • Email text template

    Dear ${ or ''},
    ${object.sudo().type_id.display_name} ${}
    assigned to ${}
    has Failed the SLA.
    Here, we use "" to display the name of the manager. Other placeholders are set as in the previous example. "${}" is also used as a link to open the request from the email.


Email Configuration

We set the sender address as in the previous template.

Let's send this email to the Working Email Address of the manager. In the To (Emails) field, write the following:


Advanced Settings

We also specify the translation language of the manager for this email.

We can now save the template and the action.

And here is an email example sent to the manager of the Demo User that failed the SLA.

Now, we will create 2 actions for the Reaction Time SLA Rule, when a request has not been assigned yet.

Automated Action: send email on SLA Warning to all Team members

The action form will have the following configuration:

1. Events: SLA Warning.

2. Event Conditions: SLA Rule type - Unassigned.

3. Type: Send Email.

And we need to create a template to send emails to all team members of the Frontend team.

Content Tab

  • Subject

    SLA Warning: ${object.display_name}

  • Email text template

    Unassigned ${object.sudo().type_id.display_name} ${} has reached the SLA Warning.

Email Configuration

  • From

    ${( and '"%s" <%s>' % (, or '')|safe}

  • To (Partners). This field expects comma-separated ids of recipient partners (as a string). We need to write the following code to get team member ids of the Frontend team.

    ${ ','.join(map(str, user.env[''].search([('name', '=', 'Frontend team')], limit=1).team_member_ids.mapped(''))) }

Short description of a code:

  • user.env[''].search([('name', '=', 'Frontend team')], limit=1)

    This part of code finds team object with the name "Frontend team".

  • .team_member_ids.mapped('')

    Gets team member ids from that team object; then gets each team member user id; and then gets partner id of these users from the partner model.

  • map(str, ...)

    Python built-in map() function, which in our case converts resulting ids into a string.

  • ','.join(...)

    Python str.join() function, in our case it separates result with commas.


In multilingual companies, where the team name can be translated, this part of code may cause errors.
In that case, better not to use the search by team name, but use team id instead.
To get the required team id, you can open the team form. The id may be obtained from the address bar.

And the code in the To (Partners) field that gets partner recipients ids can be as follows:
${ ','.join(map(str, user.env[''].browse(4).team_member_ids.mapped(''))) }

Advanced Settings

We can also specify the translation language of the team leader for the current email.

${ user.env[''].browse(4).leader_id.lang }

An email example of the configured template looks like this:

Automated Action: send email on SLA Limit to a Team leader

And the last action we need to set up is an action that will automatically send an email to the team leader if SLA of the unassigned request fails.

The action will have the following configuration:

Email Template config:

  • Subject

    SLA Failed: ${object.display_name}


  • Email text template

    Dear ${ user.env[''].browse(4) or ''},
    ${object.sudo().type_id.display_name} ${}
    has Failed the SLA.

Email Configuration

  • From

    ${( and '"%s" <%s>' % (, or '')|safe}

  • To (Partners)

    ${ user.env[''].browse(4) }

    This code will get the partner id of the team leader

Advanced Settings

The translation language for the team leader is set as in the previous template.

${ user.env[''].browse(4).leader_id.lang }

Email that will be sent using this template looks like this:

The configuration is complete. Now our system can recognize active SLA rule at any stage of request processing and send the appropriate messages to the right persons in case of SLA Warning or SLA Failed.

Follow our blog for the latest news and configuration guides.

Configure Service Level Agreement for Incident Requests