Browse Source

Merge 1dd549e2e0 into f73a7e9217

pull/365/merge
fkantelberg 5 years ago
committed by GitHub
parent
commit
c7f17012fa
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      base_mail_bcc/__init__.py
  2. 14
      base_mail_bcc/__manifest__.py
  3. 9
      base_mail_bcc/demo/mail_bcc_demo.xml
  4. 14
      base_mail_bcc/i18n/base_mail_bcc.pot
  5. 5
      base_mail_bcc/models/__init__.py
  6. 45
      base_mail_bcc/models/ir_mail_server.py
  7. 2
      base_mail_bcc/readme/DESCRIPTION.rst
  8. 4
      base_mail_bcc/readme/INSTALL.rst
  9. 4
      base_mail_bcc/tests/__init__.py
  10. 20
      base_mail_bcc/tests/test_base_mail_bcc.py

5
base_mail_bcc/__init__.py

@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# © 2014-2019 Thomas Rehn (initOS GmbH)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import models

14
base_mail_bcc/__manifest__.py

@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
# © 2014-2019 Thomas Rehn (initOS GmbH)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "BCC all emails",
"version": "10.0.1.0.0",
"depends": ["base"],
'author': 'initOS GmbH, Odoo Community Association (OCA)',
"category": "Tools",
'license': 'AGPL-3',
'demo': ['demo/mail_bcc_demo.xml'],
'installable': True,
'auto_install': False,
}

9
base_mail_bcc/demo/mail_bcc_demo.xml

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<record id="mail_bcc" model="ir.config_parameter">
<field name="key">base_mail_bcc.bcc_to</field>
<field name="value">root@example.com</field>
</record>
</data>
</odoo>

14
base_mail_bcc/i18n/base_mail_bcc.pot

@ -0,0 +1,14 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

5
base_mail_bcc/models/__init__.py

@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# © 2014-2019 Thomas Rehn (initOS GmbH)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import ir_mail_server

45
base_mail_bcc/models/ir_mail_server.py

@ -0,0 +1,45 @@
# -*- coding: utf-8 -*-
# © 2014-2019 Thomas Rehn (initOS GmbH)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from email.Utils import COMMASPACE
from odoo import api, models
class IrMailServer(models.Model):
_inherit = "ir.mail_server"
@api.model
def send_email(self, message, mail_server_id=None, smtp_server=None,
smtp_port=None, smtp_user=None, smtp_password=None,
smtp_encryption=None, smtp_debug=False):
""""Add global bcc email addresses"""
# These are added here in send_email instead of build_email
# because build_email is independent from the database and does not
# have a cursor as parameter.
ir_config_parameter = self.env["ir.config_parameter"]
config_email_bcc = ir_config_parameter.\
get_param("base_mail_bcc.bcc_to")
if config_email_bcc:
config_email_bcc = config_email_bcc.encode('ascii')
existing_bcc = []
if message['Bcc']:
existing_bcc.append(message['Bcc'])
del message['Bcc']
message['Bcc'] = COMMASPACE.join(
existing_bcc + config_email_bcc.split(',')
)
return super(IrMailServer, self).send_email(
message,
mail_server_id=mail_server_id,
smtp_server=smtp_server,
smtp_port=smtp_port,
smtp_user=smtp_user,
smtp_password=smtp_password,
smtp_encryption=smtp_encryption,
smtp_debug=smtp_debug
)

2
base_mail_bcc/readme/DESCRIPTION.rst

@ -0,0 +1,2 @@
This module extends the email mechanism to allow for sending a blind carbon copy (BCC)
of all outgoing emails to configurable e-mail addresses.

4
base_mail_bcc/readme/INSTALL.rst

@ -0,0 +1,4 @@
To configure this module, you need to:
* Go to Settings > Parameters > System Parameters
* Create a new entry with key `base_mail_bcc.bcc_to` and set the desired e-mail addresses for BCC as value. This value must be a comma-separated list of valid e-mail addresses.

4
base_mail_bcc/tests/__init__.py

@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# © 2017-2019 initOS GmbH <https://www.initos.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import test_base_mail_bcc

20
base_mail_bcc/tests/test_base_mail_bcc.py

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# © 2017-2019 initOS GmbH <https://www.initos.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import mock
from odoo.tests.common import TransactionCase
class TestBaseMailBcc(TransactionCase):
def test_base_mail_bcc(self):
ir_mail_server = self.env['ir.mail_server']
message = ir_mail_server.build_email(
email_from='admin@example.com',
email_to='admin@example.com',
email_bcc='unused@example.com',
subject='An example E-Mail',
body='With an example body',
)
with mock.patch("smtplib.SMTP"):
ir_mail_server.send_email(message)
Loading…
Cancel
Save