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

My first attempt at this was not optimal, and many thanks to Pierre de Giorgio, who posted a better solution in the comments.

Note that the Models have different names in Odoo 12:

  • Mass Mailing Contact (
  • Mailing List (mail.mass_mailing.list)
  • Model = Contact (res.partner)
  • Action To Do = Execute Python Code
  • Trigger Condition = On Creation
  • Apply on = Email is set
    • [["email","!=",False]]

Python Code

contact_name =
contact_email =
contact_company =
ref_model = env['']
existing_records = env[''].search([('email', '=', contact_email)])
if len(existing_records) == 0:
new_entry = ref_model.create({'name':contact_name, 'email':contact_email,'company_name':contact_company,'list_ids' : [(6,0,[1,2])]})

7 thoughts on “Add contacts to mailing lists using Automated Actions

  1. Hi,
    I have a similar issue with Odoo 12, I would appreciate if you can suggest me an approach to solve it.

    What I want to accomplish is this:
    – We have a new applicant in the Recruitment module, and is tagged with ‘wordpress’.
    – The recruiter rate the applicant with 2 or 3 appreciation.

    Using an automated action, I would like to add the applicant email to a special WordPress engineers mail list, automatically when the rate occurs.

    I am using Odoo 12, so I face the same issue as the post explain.

    And on top, I cannot update the list_id attribute, because my record is an Applicant, not a Contact.

    I would really appreciate your help.


  2. For Odoo 12 you can try putting all of this is python code. This is how I did it. I also do a quick check to make sure the email address doesn’t exist before creating the new entry. If you do it as outlined in the above example, try changing the line for the mailing lists from [1,2] to [6,0,[1,2])]. That should eliminate the need for the second automated action.

    My example also eliminates the need for the second automated example.

    Hope this helps.

    contact_name =
    contact_email =
    contact_company =

    ref_model = env[‘’]
    existing_records = env[‘’].search([(’email’, ‘=’, contact_email)])
    if len(existing_records) == 0:
    new_entry = ref_model.create({‘name’:contact_name, ’email’:contact_email,’company_name’:contact_company,’list_ids’ : [(6,0,[1])]})

    Liked by 2 people

  3. Hi,

    Thank you for your solution, it is working fine for me to transfer a new contact to a specific mailing list. I have trouble updating an already existing contact in a list. I can’t update a contact in a mailing list from the automation panel (or I do not know how to do it). Any idea ?

    Thank you for your work !


  4. Hi, thanks for your help.

    How to only update a field. For example, if I update a Opportunity related with a customer, I want to automatically update a field in customer with the information in a field that I have in the current opportunity.



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