Compare commits
3 Commits
10.0
...
10.0-ADD-m
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b57485cf7c | ||
|
|
20dcf1a333 | ||
|
|
7c7cb2e8d2 |
13
mail_single_send_several_recipients/README.rst
Normal file
13
mail_single_send_several_recipients/README.rst
Normal 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)
|
||||
3
mail_single_send_several_recipients/__init__.py
Normal file
3
mail_single_send_several_recipients/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import models
|
||||
12
mail_single_send_several_recipients/__manifest__.py
Normal file
12
mail_single_send_several_recipients/__manifest__.py
Normal 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,
|
||||
}
|
||||
3
mail_single_send_several_recipients/models/__init__.py
Normal file
3
mail_single_send_several_recipients/models/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import mail_mail
|
||||
29
mail_single_send_several_recipients/models/mail_mail.py
Normal file
29
mail_single_send_several_recipients/models/mail_mail.py
Normal 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
|
||||
Reference in New Issue
Block a user