diff --git a/base_mail_sender_bcc/__init__.py b/base_mail_sender_bcc/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/base_mail_sender_bcc/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/base_mail_sender_bcc/__manifest__.py b/base_mail_sender_bcc/__manifest__.py new file mode 100644 index 0000000..db52c3a --- /dev/null +++ b/base_mail_sender_bcc/__manifest__.py @@ -0,0 +1,21 @@ +# Copyright 2017-2022 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + 'name': 'Mail Sender Bcc', + 'version': '14.0.1.0.0', + 'category': 'Mail', + 'license': 'AGPL-3', + 'summary': "Always send a copy of the mail to the sender", + 'description': """ +Mail Sender Bcc +=============== + +With this module, when Odoo sends an outgoing email, it adds the sender as Bcc (blind copy) of the email. + """, + 'author': 'Akretion', + 'website': 'https://github.com/akretion/odoo-usability', + 'depends': ['base'], + 'installable': True, +} diff --git a/base_mail_sender_bcc/models/__init__.py b/base_mail_sender_bcc/models/__init__.py new file mode 100644 index 0000000..abbcb50 --- /dev/null +++ b/base_mail_sender_bcc/models/__init__.py @@ -0,0 +1 @@ +from . import ir_mail_server diff --git a/base_mail_sender_bcc/models/ir_mail_server.py b/base_mail_sender_bcc/models/ir_mail_server.py new file mode 100644 index 0000000..d19f50a --- /dev/null +++ b/base_mail_sender_bcc/models/ir_mail_server.py @@ -0,0 +1,27 @@ +# Copyright 2017-2022 Akretion France +# @author: Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models + + +class IrMailServer(models.Model): + _inherit = 'ir.mail_server' + + def build_email( + self, email_from, email_to, subject, body, email_cc=None, + email_bcc=None, reply_to=False, attachments=None, + message_id=None, references=None, object_id=False, + subtype='plain', headers=None, + body_alternative=None, subtype_alternative='plain'): + if email_from: + if email_bcc is None: + email_bcc = [email_from] + elif isinstance(email_bcc, list) and email_from not in email_bcc: + email_bcc.append(email_from) + return super().build_email( + email_from, email_to, subject, body, email_cc=email_cc, + email_bcc=email_bcc, reply_to=reply_to, attachments=attachments, + message_id=message_id, references=references, object_id=object_id, + subtype=subtype, headers=headers, + body_alternative=body_alternative, subtype_alternative=subtype_alternative)