Skip to content

Commit 54703c2

Browse files
committed
Merge PR #4639 into 16.0
Signed-off-by eLBati
2 parents a9f4de7 + dbcc386 commit 54703c2

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

l10n_it_fatturapa_pec/models/sdi.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,9 @@ def send_via_pec(self, attachment_out_ids):
133133
self._check_fetchmail()
134134
self.check_first_pec_sending()
135135
user = self.env.user
136-
company = user.company_id
137136
for att in attachment_out_ids:
137+
company = att.company_id
138+
channel_id = att.channel_id
138139
if not att.datas or not att.name:
139140
raise UserError(_("File content and file name are mandatory"))
140141
mail_message = self.env["mail.message"].create(
@@ -149,7 +150,7 @@ def send_via_pec(self, attachment_out_ids):
149150
"attachment_ids": [(6, 0, att.ir_attachment_id.ids)],
150151
"email_from": (company.email_from_for_fatturaPA),
151152
"reply_to": (company.email_from_for_fatturaPA),
152-
"mail_server_id": company.sdi_channel_id.pec_server_id.id,
153+
"mail_server_id": channel_id.pec_server_id.id,
153154
}
154155
)
155156

l10n_it_sdi_channel/models/fatturapa_attachment_out.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ def send_to_sdi(self):
3333
states = self.mapped("state")
3434
if set(states) != {"ready"}:
3535
raise UserError(_("You can only send files in 'Ready to Send' state."))
36+
channel_ids = self.mapped("channel_id")
37+
if len(channel_ids) > 1:
38+
raise UserError(_("You can only send files with the same channel."))
3639

37-
company = self.env.company
38-
sdi_channel = company.sdi_channel_id
40+
sdi_channel = self.channel_id
3941
send_result = sdi_channel.send(self)
4042
return send_result
4143

0 commit comments

Comments
 (0)