diff --git a/base_mail_sender_bcc/__manifest__.py b/base_mail_sender_bcc/__manifest__.py index caae967..5c894d4 100644 --- a/base_mail_sender_bcc/__manifest__.py +++ b/base_mail_sender_bcc/__manifest__.py @@ -17,5 +17,8 @@ With this module, when Odoo sends an outgoing email, it adds the sender as Bcc ( 'author': 'Akretion', 'website': 'https://github.com/akretion/odoo-usability', 'depends': ['base'], - 'installable': True, + # I set it to False, because this module doesn't work because of send_validated_to in context + # cf method _prepare_email_message() + # We should now use the module mail_composer_cc_bcc from OCA/social (moved to OCA/mail) + 'installable': False, } diff --git a/base_usability_akretion/models/ir_mail_server.py b/base_usability_akretion/models/ir_mail_server.py index 9d2381f..17ea4dd 100644 --- a/base_usability_akretion/models/ir_mail_server.py +++ b/base_usability_akretion/models/ir_mail_server.py @@ -18,21 +18,24 @@ class IrMailServer(models.Model): smtp_ssl_certificate=None, smtp_ssl_private_key=None, smtp_debug=False, smtp_session=None): # Start copy from native method - smtp = smtp_session - if not smtp: - smtp = self.connect( + if not smtp_session: + smtp_session = self.connect( smtp_server, smtp_port, smtp_user, smtp_password, smtp_encryption, - smtp_from=message['From'], ssl_certificate=smtp_ssl_certificate, ssl_private_key=smtp_ssl_private_key, - smtp_debug=smtp_debug, mail_server_id=mail_server_id,) - + smtp_from=message['From'], ssl_certificate=smtp_ssl_certificate, + ssl_private_key=smtp_ssl_private_key, + smtp_debug=smtp_debug, mail_server_id=mail_server_id) + # _prepare_email_message() will remove the Bcc field in message + # that's why we need to save it and re-inject it in message + email_bcc = message['Bcc'] smtp_from, smtp_to_list, message = self._prepare_email_message( - message, smtp) + message, smtp_session) + message['Bcc'] = email_bcc # End copy from native method logger.info( "Sending email from '%s' to '%s' Cc '%s' Bcc '%s' " - "with subject '%s'", + "with subject '%s'. smtp_to_list=%s", smtp_from, message.get('To'), message.get('Cc'), - message.get('Bcc'), message.get('Subject')) + message.get('Bcc'), message.get('Subject'), smtp_to_list) return super().send_email( message, mail_server_id=mail_server_id, smtp_server=smtp_server, smtp_port=smtp_port,