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.

34 lines
1.1 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_email, reason):
  19. return self.write({'email_bounced': True})
  20. @api.multi
  21. def write(self, vals):
  22. email = vals.get('email')
  23. if email is not None:
  24. vals['email_bounced'] = (
  25. bool(email) and
  26. self.env['mail.tracking.email'].email_is_bounced(email))
  27. return super(MailMassMailingContact, self).write(vals)