Browse Source

[FIX] Update email_score when email changes

pull/318/head
Antonio Espinosa 8 years ago
committed by ernesto
parent
commit
a7fac21db8
  1. 7
      mail_tracking/models/mail_tracking_email.py
  2. 5
      mail_tracking/models/res_partner.py

7
mail_tracking/models/mail_tracking_email.py

@ -126,6 +126,13 @@ class MailTrackingEmail(models.Model):
# Consider only last 10 tracking emails # Consider only last 10 tracking emails
return self.sorted(key=lambda r: r.time, reverse=True)[:10] return self.sorted(key=lambda r: r.time, reverse=True)[:10]
@api.model
def email_score_from_email(self, email):
trackings = self.env['mail.tracking.email'].search([
('recipient_address', '=ilike', email)
])
return trackings.email_score()
@api.multi @api.multi
def email_score(self): def email_score(self):
"""Default email score algorimth""" """Default email score algorimth"""

5
mail_tracking/models/res_partner.py

@ -40,6 +40,7 @@ class ResPartner(models.Model):
def write(self, vals): def write(self, vals):
email = vals.get('email') email = vals.get('email')
if email is not None: if email is not None:
vals['tracking_email_ids'] = \
self.env['mail.tracking.email']._tracking_ids_to_write(email)
m_track = self.env['mail.tracking.email']
vals['tracking_email_ids'] = m_track._tracking_ids_to_write(email)
vals['email_score'] = m_track.email_score_from_email(email)
return super(ResPartner, self).write(vals) return super(ResPartner, self).write(vals)
Loading…
Cancel
Save