Add applicants to mailing lists using Automated Actions

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

The requirement is to add a new applicant to a mailing list when the appreciation is changed to Very Good (2 stars) or Excellent (3 stars).

Automated Action

Start by enabling Developer Mode and navigating to Settings / Technical / (Automation) / Automated Actions:

Create a new Automated Action as shown:

  • Model = Applicant
  • Action To Do = Execute Python Code
  • Model (to write records) = Mailing Contact ​
  • Trigger Condition = On Update
  • Before Update Domain
    • Email is set and Appreciation is Normal or Good
    • ["&",["email_from","!=",""],"|",["priority","=","0"],["priority","=","1"]]
  • Apply on
    • Email is set and Appreciation is Very Good or Excellent
    • ["&",["email_from","!=",""],"|",["priority","=","2"],["priority","=","3"]]

Python Code

env['mail.mass_mailing.contact'].create({
'name':record.name,
'email':record.email_from,
'list_ids':[1,2]
})

Note that you will need to replace the list ids with the IDs of the mailing list(s), as explained here

This could create multiple records on the Mailing List in certain circumstances

One thought on “Add applicants to mailing lists using Automated Actions

Leave a Reply

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

WordPress.com Logo

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

Facebook photo

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

Connecting to %s