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.

24 lines
869 B

  1. # -*- coding: utf-8 -*-
  2. # © 2016 Antonio Espinosa - <antonio.espinosa@tecnativa.com>
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. import logging
  5. from openerp import api, SUPERUSER_ID
  6. _logger = logging.getLogger(__name__)
  7. def post_init_hook(cr, registry):
  8. with api.Environment.manage():
  9. env = api.Environment(cr, SUPERUSER_ID, {})
  10. # Recalculate all partner tracking_email_ids
  11. partners = env['res.partner'].search([
  12. ('email', '!=', False),
  13. ])
  14. emails = partners.mapped('email')
  15. _logger.info(
  16. "Recalculating 'tracking_email_ids' in 'res.partner' "
  17. "model for %d email addresses", len(emails))
  18. for email in emails:
  19. env['mail.tracking.email'].tracking_ids_recalculate(
  20. 'res.partner', 'email', 'tracking_email_ids', email)