You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
1.1 KiB

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!-- Copyright 2018 Tecnativa - Jairo Llopis
  3. Copyright 2019 initOS GmbH - Florian Kantelberg
  4. License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
  5. <data>
  6. <record id="sync_blacklist" model="ir.actions.server">
  7. <field name="name">Sync partner's email blacklist status</field>
  8. <field name="model_id" ref="model_privacy_consent"/>
  9. <field name="crud_model_id" ref="base.model_res_partner"/>
  10. <field name="state">code</field>
  11. <field name="code">
  12. for consent in records:
  13. email = consent.partner_id.email
  14. # Skip records without email, although highly improbable
  15. if not email:
  16. continue
  17. # Choose method to sync acceptance and blacklisting
  18. if consent.accepted:
  19. method = env["mail.blacklist"]._remove
  20. else:
  21. method = env["mail.blacklist"]._add
  22. # Apply user desire
  23. method(email)
  24. </field>
  25. </record>
  26. </data>