Add contacts to mailing lists using Automated Actions

Another example of using Automated Actions to setup data in other Models (database tables).

The requirements are to add a new contact to:

  1. Mailing Contacts AND
  2. One or more Mailing Lists

We can do this because there is a many2many field on the Mailing Contact for Mailing Lists.

We therefore need to know the Record IDs of the Mailing Lists. Odoo Studio makes it simple to do that (as shown below), but the standard download tool is another option.

In this example we will use the two mailing lists with Records IDs of 1 & 2 but you can use any Mailing Lists you have created.

Automated Action

Now we have all the information we need, so we can enable Developer Mode and navigate to Settings / Technical / (Automation) / Automated Actions:

Create a new Automated Action as shown:

  • Model = Contact
  • Action To Do = Create a new Record
  • Create/Write Target Model = Mailing Contact ​
  • Trigger Condition = On Creation
  • Apply on = Email is set
    • Domain [["email","!=",False]]

Data to Write:

FieldEvaluation TypeValue
Name (
Email (
Mailing Lists ( expression[1,2]
Company Name (

Odoo 12

For reasons I don’t fully understand, the above does not work in Odoo 12, so here is a workaround.

Note that the Models have different names in Odoo 12:

  • Mass Mailing Contact (
  • Mailing List (mail.mass_mailing.list)

Create another Automated Action to be triggered when a record is created on Mass Mailing Contact (

  • Model = Mass Mailing Contact (
  • Action To Do = Execute Python Code
  • Trigger Condition = On Creation
  • Apply on = Mailing Lists is not set
    • [["list_ids","=",False]]

Python Code

record['list_ids'] = [1,2]

It should be possible to improve this, either by merging the two Automated Actions into one or by adding some conditions. Suggestions welcome!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s