Skip to content

[FIX] l10n_it_fatturapa_pec: avoid changing email on user when testing smtp connection #4700

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions l10n_it_fatturapa_pec/models/ir_mail_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,11 @@ class IrMailServer(models.Model):
is_fatturapa_pec = fields.Boolean("E-invoice PEC server")
email_from_for_fatturaPA = fields.Char("Sender Email Address")

def test_smtp_connection(self):
for server in self:
if server.is_fatturapa_pec:
# self.env.user.email is used to test SMTP connection
server.env.user.email = server.email_from_for_fatturaPA
# no need to revert to correct email: UserError is always raised and
# rollback done
return super().test_smtp_connection()
def _get_test_email_addresses(self):
email_from, email_to = super()._get_test_email_addresses()
if self.is_fatturapa_pec:
email_from = self.email_from_for_fatturaPA
return email_from, email_to

@api.model
def _search(
Expand Down