[ADD] mail_single_send_several_recipients module

This commit is contained in:
Chafique
2020-09-28 12:06:38 +02:00
parent a748de39ec
commit 7c7cb2e8d2
5 changed files with 59 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
Mail Single Send with Several Recipients
========================================
With this module, when there are several recipients,
Odoo send only one e-mail with all the addressees and no, one email per address.
Credits
=======
Contributors
------------
* Chafique Delli (chafique.delli@akretion.com)

View File

@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import models

View File

@@ -0,0 +1,12 @@
# -*- coding: utf-8 -*-
{
'name': 'Mail Single Send with Several Recipients',
'version': '10.0.1.0.0',
'category': 'Mail',
'license': 'AGPL-3',
'summary': "When there are several recipients, always send only one e-mail for all the addressees",
'author': 'Akretion',
'website': 'http://www.akretion.com',
'depends': ['mail'],
'installable': True,
}

View File

@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import mail_mail

View File

@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
from odoo import models, api
from email.utils import formataddr
class MailMail(models.Model):
_inherit = 'mail.mail'
@api.multi
def send(self, auto_commit=False, raise_exception=False):
for mail in self:
email_to = []
for partner in mail.recipient_ids:
for partner_email in [formataddr((partner.name, partner.email))]:
email_to.append(partner_email)
mail.email_to = email_to
return super(MailMail, self).send(auto_commit=auto_commit,
raise_exception=raise_exception)
@api.multi
def send_get_mail_to(self, partner=None):
self.ensure_one()
email_to = []
for partner in self.recipient_ids:
email_to.append(formataddr((partner.name, partner.email)))
self.recipient_ids = [(6, 0, [])]
return email_to