[FIX] l10n_it_edi: sent certified email without reply-to or return-path
Before this commit, when the domain alias was set (e.g. my_domain.com), the reply-to and the reply-path were filled with default values using this domain (e.g. reply-to : catchall@my_domain.com and reply-path: Return-Path: bounce+number@my_domain.com). As we have a second SMTP server, the certified email (https://en.wikipedia.org/wiki/Certified_email), with a different domain than the domain alias filled in the settings, the SMTP servers will arise an error : "SMTPRecipientsRefused: Sender address rejected: not owned by user", this error arise because the domain of the certified email is different from the one setted in the settings, is also different from the domains of the reply-to and the return-path. Now, when we know that we are going to use the certified email SMTP server, for example to send invoices to the Italian government, the email will be sent without a reply-to or without a reply-path. This behaviour is exactly the same as the behaviour will have if we didn't set a domain alias. opw-2045244 X-original-commit: 66c5053
This commit is contained in:
@@ -273,11 +273,12 @@ class AccountInvoice(models.Model):
|
||||
'subject': _('Sending file: %s') % (self.l10n_it_einvoice_id.name),
|
||||
'body': _('Sending file: %s to ES: %s') % (self.l10n_it_einvoice_id.name, self.env.user.company_id.l10n_it_address_recipient_fatturapa),
|
||||
'email_from': self.env.user.company_id.l10n_it_address_send_fatturapa,
|
||||
'reply_to': self.env.user.company_id.l10n_it_address_send_fatturapa,
|
||||
'mail_server_id': self.env.user.company_id.l10n_it_mail_pec_server_id.id,
|
||||
'attachment_ids': [(6, 0, self.l10n_it_einvoice_id.ids)],
|
||||
})
|
||||
|
||||
mail_fattura = self.env['mail.mail'].create({
|
||||
mail_fattura = self.env['mail.mail'].with_context(wo_return_path=True).create({
|
||||
'mail_message_id': message.id,
|
||||
'email_to': self.env.user.company_id.l10n_it_address_recipient_fatturapa,
|
||||
})
|
||||
|
||||
@@ -356,3 +356,17 @@ class FetchmailServer(models.Model):
|
||||
if descrizione:
|
||||
output_str += "<li>Errore %s: %s</li>" % (element[0].text, descrizione)
|
||||
return output_str + "</ul>"
|
||||
|
||||
class IrMailServer(models.Model):
|
||||
_name = "ir.mail_server"
|
||||
_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 self.env.context.get('wo_return_path') and headers:
|
||||
headers.pop('Return-Path', False)
|
||||
return super(IrMailServer, self).build_email(email_from, email_to, subject, body, email_cc, email_bcc, reply_to,
|
||||
attachments, message_id, references, object_id, subtype, headers,
|
||||
body_alternative, subtype_alternative)
|
||||
|
||||
Reference in New Issue
Block a user