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.

35 lines
1.2 KiB

  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. from openerp import models, api, fields
  5. class MailMassMailingContact(models.Model):
  6. _inherit = 'mail.mass_mailing.contact'
  7. email_bounced = fields.Boolean(string="Email bounced")
  8. email_score = fields.Float(
  9. string="Email score", readonly=True, store=False,
  10. compute='_compute_email_score')
  11. @api.multi
  12. @api.depends('email')
  13. def _compute_email_score(self):
  14. for contact in self.filtered('email'):
  15. contact.email_score = self.env['mail.tracking.email'].\
  16. email_score_from_email(contact.email)
  17. @api.multi
  18. def email_bounced_set(self, tracking_emails, reason, event=None):
  19. contacts = self.filtered(lambda r: not r.email_bounced)
  20. return contacts.write({'email_bounced': True})
  21. @api.multi
  22. def write(self, vals):
  23. email = vals.get('email')
  24. if email is not None:
  25. vals['email_bounced'] = (
  26. bool(email) and
  27. self.env['mail.tracking.email'].email_is_bounced(email))
  28. return super(MailMassMailingContact, self).write(vals)