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.

28 lines
961 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. from openerp import models, api, fields
  5. class MailMassMailingContact(models.Model):
  6. _inherit = 'mail.mass_mailing.contact'
  7. tracking_email_ids = fields.Many2many(
  8. string="Tracking emails", comodel_name="mail.tracking.email",
  9. readonly=True)
  10. email_score = fields.Float(
  11. string="Email score", readonly=True, default=50.0)
  12. @api.multi
  13. def email_score_calculate(self):
  14. for contact in self:
  15. contact.email_score = contact.tracking_email_ids.email_score()
  16. @api.multi
  17. def write(self, vals):
  18. email = vals.get('email')
  19. if email is not None:
  20. vals['tracking_email_ids'] = \
  21. self.env['mail.tracking.email']._tracking_ids_to_write(email)
  22. return super(MailMassMailingContact, self).write(vals)