Skip to content

Commit

Permalink
Merge pull request #734 from camptocamp/15.0-fix-l10n_ch_invoice_repo…
Browse files Browse the repository at this point in the history
…rts_should_print_invoice_attachment

[15.0][FIX] l10n_ch_invoice_reports should_print_invoice_attachment
  • Loading branch information
TDu authored Sep 20, 2024
2 parents 34b5f9c + 8b59cd5 commit 021a9d7
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions l10n_ch_invoice_reports/models/mail_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ def generate_email(self, res_ids, fields=None):
result = super().generate_email(res_ids, fields)
if self._should_print_invoice_attachment():
for invoice in self.env[self.model_id.model].browse(res_ids):
invoice_attachments = self.generate_invoice_attachment(invoice)
result[invoice.id]["attachments"] = invoice_attachments
if invoice.company_id.partner_id.country_id.code == "CH":
invoice_attachments = self.generate_invoice_attachment(invoice)
result[invoice.id]["attachments"] = invoice_attachments
return result

def _should_print_invoice_attachment(self):
Expand All @@ -27,7 +28,12 @@ def _should_print_invoice_attachment(self):
if (
self.model_id.model == "account.move"
and self.report_template.report_name
== "l10n_ch_invoice_reports.account_move_payment_report"
in (
# Called from action Invoice with payment slip(s)
"l10n_ch_invoice_reports.account_move_payment_report",
# Called from Send & Print button
"account.report_invoice_with_payments",
)
):
return True

Expand Down

0 comments on commit 021a9d7

Please sign in to comment.