[FIX] base_usability: ir_mail_server avoid breaking Bcc
fix code for smtp_session in inherit of send_email() Disable module base_mail_sender_bcc that just doesn't work in v16 ; as it's a design problem, I don't plan to fix it.
This commit is contained in:
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user