[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',
|
'author': 'Akretion',
|
||||||
'website': 'https://github.com/akretion/odoo-usability',
|
'website': 'https://github.com/akretion/odoo-usability',
|
||||||
'depends': ['base'],
|
'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_ssl_certificate=None, smtp_ssl_private_key=None,
|
||||||
smtp_debug=False, smtp_session=None):
|
smtp_debug=False, smtp_session=None):
|
||||||
# Start copy from native method
|
# Start copy from native method
|
||||||
smtp = smtp_session
|
if not smtp_session:
|
||||||
if not smtp:
|
smtp_session = self.connect(
|
||||||
smtp = self.connect(
|
|
||||||
smtp_server, smtp_port, smtp_user, smtp_password, smtp_encryption,
|
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_from=message['From'], ssl_certificate=smtp_ssl_certificate,
|
||||||
smtp_debug=smtp_debug, mail_server_id=mail_server_id,)
|
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(
|
smtp_from, smtp_to_list, message = self._prepare_email_message(
|
||||||
message, smtp)
|
message, smtp_session)
|
||||||
|
message['Bcc'] = email_bcc
|
||||||
# End copy from native method
|
# End copy from native method
|
||||||
logger.info(
|
logger.info(
|
||||||
"Sending email from '%s' to '%s' Cc '%s' Bcc '%s' "
|
"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'),
|
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(
|
return super().send_email(
|
||||||
message, mail_server_id=mail_server_id,
|
message, mail_server_id=mail_server_id,
|
||||||
smtp_server=smtp_server, smtp_port=smtp_port,
|
smtp_server=smtp_server, smtp_port=smtp_port,
|
||||||
|
|||||||
Reference in New Issue
Block a user