Skip to content

Commit c46ffa6

Browse files
committed
[FIX] l10n_it_fatturapa_pec - user without permission to access settings can send a PEC
1 parent d63c837 commit c46ffa6

2 files changed

Lines changed: 16 additions & 10 deletions

File tree

l10n_it_fatturapa_pec/models/fatturapa_attachment_out.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,19 @@ def send_via_pec(self):
6363
}
6464
)
6565

66-
mail = self.env["mail.mail"].create(
67-
{
68-
"mail_message_id": mail_message.id,
69-
"body_html": mail_message.body,
70-
"email_to": self.env.company.email_exchange_system,
71-
"headers": {
72-
"Return-Path": self.env.company.email_from_for_fatturaPA
73-
},
74-
}
66+
mail = (
67+
self.env["mail.mail"]
68+
.sudo()
69+
.create(
70+
{
71+
"mail_message_id": mail_message.id,
72+
"body_html": mail_message.body,
73+
"email_to": self.env.company.email_exchange_system,
74+
"headers": {
75+
"Return-Path": self.env.company.email_from_for_fatturaPA
76+
},
77+
}
78+
)
7579
)
7680

7781
if mail:

l10n_it_fatturapa_pec/models/sdi.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ def check_email_validity(self):
8585
)
8686

8787
def check_first_pec_sending(self):
88-
sdi_address = self.env["ir.config_parameter"].get_param("sdi.pec.first.address")
88+
sdi_address = (
89+
self.env["ir.config_parameter"].sudo().get_param("sdi.pec.first.address")
90+
)
8991
if not self.first_invoice_sent:
9092
if self.email_exchange_system != sdi_address:
9193
raise exceptions.UserError(

0 commit comments

Comments
 (0)