Skip to content
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

[WIP][14.0][IMP] account_invoice_batches: report intermediary service #426

Open
wants to merge 1 commit into
base: 14.0
Choose a base branch
from

Conversation

FrankC013
Copy link
Contributor

No description provided.

@@ -14,6 +14,7 @@
"l10n_es_facturae",
"account_invoice_report_service",
"sale_order_invoicing_grouping_criteria",
"account_move_service",
Copy link
Member

@eantones eantones Sep 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot make this dependent, we have to allow having batches without move service.

Comment on lines +158 to +206
report_service = self.company_id.report_service_id
if invoices_pdf.filtered(lambda x: x.partner_id.service_intermediary):
if not self.company_id.report_intermediary_service_id:
raise UserError(
_(
"The report for service intermediary partners is not "
"defined in the configuration settings. Please go to "
"the billing configuration and specify which report "
"will be used."
)
)
report_intermediary = self.company_id.report_intermediary_service_id
pdf_streams = []
for invoice in invoices_pdf:
if invoice.partner_id.service_intermediary:
if not report_intermediary:
raise UserError(
_(
"The report for service intermediary partners is not "
"defined in the configuration settings. Please go to "
"the billing configuration and specify which report "
"will be used."
)
)
report = report_intermediary
else:
report = report_service

pdf_content, _p = report._render_qweb_pdf([invoice.id])
pdf_stream = io.BytesIO(pdf_content)
pdf_streams.append(pdf_stream)

if pdf_streams:
merged_pdf_stream = io.BytesIO()
pdf_merger = PdfFileReader(pdf_content)
for pdf_stream in pdf_streams:
pdf_merger.append(pdf_stream)
pdf_merger.write(merged_pdf_stream)
pdf_merger.close()

return {
"type": "ir.actions.report",
"report_type": "qweb-pdf",
"data": {"pdf_content": merged_pdf_stream.getvalue()},
"report_name": "Merged_Invoices",
"name": _("Merged Invoices"),
}
else:
raise UserError(_("No PDFs were generated for the selected invoices."))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very messy code, copy pasted, please, try to use functions and reuse code. The original code was very clean with a few branches with little code. Please clean the code

Copy link
Member

@eantones eantones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chek the comments please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants