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.

17 lines
633 B

  1. # Copyright 2018 David Vidal <david.vidal@tecnativa.com>
  2. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
  3. from odoo import api, SUPERUSER_ID
  4. def post_init_hook(cr, registry):
  5. """Ensure all existing contacts are going to work as v10"""
  6. env = api.Environment(cr, SUPERUSER_ID, {})
  7. contacts = env['mail.mass_mailing.contact'].search([])
  8. for contact in contacts:
  9. if len(contact.list_ids) <= 1:
  10. continue
  11. list_1 = contact.list_ids[0]
  12. for list_ in contact.list_ids - list_1:
  13. contact.copy({"list_ids": [(6, 0, list_.ids)]})
  14. contact.list_ids = list_1