This question has been flagged
12 Replies
10700 Views

Hi,I am trying to find a way using an automated action to add contact to a specific mailing list once the contact has been created into Mailing contact.

I created an automated action to create a contact to Maling list contact as soon as a new contact is added, this is working fine: https://ibb.co/HdpsNJv

But I can't find a way to add this contact to a specific mailing list.  I tried that but it does not work: https://ibb.co/wSg1S6Y

Any advice?  thanks 


Avatar
Discard
Best Answer

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 = record.name
contact_email = record.email
contact_company = record.parent_id.name

ref_model = env[‘mail.mass_mailing.contact’]
existing_records = env[‘mail.mass_mailing.contact’].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])]})

Avatar
Discard

Thanks Pierre, that's an improvement on my solution!

Any tips on how to modify this to work with the crm.lead model in 16 with a server action? Trying to add to a mailing list via the marketing automation app.

Best Answer

Hi

There's a third-party app that adds contacts to mailing lists. It also has an action "Add contact to Mailing list". Perhaps this might help you?

Cheers

Mike

Avatar
Discard
Author

thanks for your feedback. I'd like to avoir adding or buyingt an extra module. I ll keep digging otherwise I will go for a specific module then.

thanks

Author

HI,

thanks for that.

Indeed it is not the best app as many app in Odoo, the are far from being compltete and need a lot of customization.

That's for me the pb with odoo system, many app but not complete unfortunately. But it does the job eventually.

cheers

Best Answer

I think I have found a solution in Odoo 13.  Let's assume that you want to add the contact to two mailing lists that have Record IDs of 1 & 2.

FieldEvaluation TypeValue

Name (mailing.contact)

Python expression

record.name

Email (mailing.contact)

Python expression

record.email

Mailing Lists (mailing.contact)

Python expression

[1,2]

If you want to add them to Mailing Lists 1,2 & 7 then the Python expression would be [1,2,7]

Screenshots and more information

EDIT: As noted in the comments, this does not work in Odoo 12, so here is a workaround

Create another Automated Action to be triggered when a record is created on Mass Mailing Contact (mail.mass_mailing.contact) - so immediately after the first Automated Action (above):

  • Model = Mass Mailing Contact (mail.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]
    Avatar
    Discard
    Author

    Hi,

    thanks for your feedback.

    I had a loot at the doc and I have tried this before but it still does now work.

    I am using v12 and indeed the model name is a bit different, as you can see but it looks the same:

    https://ibb.co/y4z8RCX

    There is no error message but it does not work. I have tried to split it into different automated action too but still the same.

    I really don't get it, this is weird.I agree it should work this way.

    Is there a way to track the log and see what it is executed in therm of query when the automated action is triggered?

    I don't see anything fro,m the log file..

    thank for your help, love the odootricks.tips :)

    Yes, although it's working in Odoo 13, I can't make it work in Odoo 12, which is strange!!

    Updated my answer with a workaround. I guess that someone with better Python knowledge could do all of this in one Automated Action :-)

    Author

    Thanks a lot, it is indeed working this way.

    cheers

    Best Answer

    Hi, may i know the name of third-party app that adds contacts to mailing lists .

    Avatar
    Discard
    Author

    Thanks,m I managed to do it through automated action