Compare commits

...

3 Commits

Author SHA1 Message Date
Chafique
b57485cf7c [FIX] call super() method in send_get_mail_to function 2020-10-02 09:58:30 +02:00
Chafique
20dcf1a333 [FIX] README.rst 2020-10-01 18:14:22 +02:00
Chafique
7c7cb2e8d2 [ADD] mail_single_send_several_recipients module 2020-09-28 12:06:38 +02:00
5 changed files with 60 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 sends only one single e-mail with all the addressees instead of 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,29 @@
# -*- 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):
super(MailMail, self).send_get_mail_to(partner=partner)
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