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.

33 lines
1.0 KiB

  1. # -*- coding: utf-8 -*-
  2. # License AGPL-3: Antiun Ingenieria S.L. - Antonio Espinosa
  3. # See README.rst file on addon root folder for more details
  4. from openerp import models, api
  5. class MailMail(models.Model):
  6. _inherit = 'mail.mail'
  7. @api.model
  8. def email_to_list_get(self, mail):
  9. email_list = []
  10. if mail.email_to:
  11. email_to = self.send_get_mail_to(mail)
  12. email_list += email_to
  13. for partner in mail.recipient_ids:
  14. email_to = self.send_get_mail_to(mail, partner=partner)
  15. email_list += email_to
  16. return email_list
  17. @api.model
  18. def create(self, vals):
  19. mail = super(MailMail, self).create(vals)
  20. if vals.get('statistics_ids'):
  21. email_list = self.email_to_list_get(mail)
  22. for stat in mail.statistics_ids:
  23. stat.write({
  24. 'email_from': mail.email_from,
  25. 'email_to': ';'.join(email_list),
  26. 'subject': mail.subject,
  27. })
  28. return mail_id