Skip to content

Commit

Permalink
[IMP] shopinvader_api_invoice: Use now available report_generate_helper
Browse files Browse the repository at this point in the history
  • Loading branch information
paradoxxxzero committed Dec 3, 2024
1 parent e73459f commit ea8965e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 10 deletions.
1 change: 1 addition & 0 deletions shopinvader_api_invoice/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
"shopinvader_schema_invoice",
"shopinvader_api_security_invoice",
"extendable_fastapi",
"report_generate_helper",
],
}
1 change: 1 addition & 0 deletions shopinvader_api_invoice/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
* Simone Orsi <[email protected]>
* Florian Mounier <[email protected]>
11 changes: 1 addition & 10 deletions shopinvader_api_invoice/routers/invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

from odoo.api import Environment
from odoo.http import content_disposition
from odoo.tools.safe_eval import safe_eval

from odoo.addons.base.models.res_partner import Partner as ResPartner
from odoo.addons.extendable_fastapi.schemas import PagedCollection
Expand Down Expand Up @@ -63,8 +62,6 @@ def download(
) -> FileResponse:
"""Download document."""
filename, pdf = get_pdf(env, invoice_id)
if not filename.lower().endswith(".pdf"):
filename += ".pdf"
header = {
"Content-Disposition": content_disposition(filename),
}
Expand All @@ -78,11 +75,5 @@ def pseudo_stream():


def get_pdf(env, record_id) -> tuple[str, bytes]:
report_name = "account.account_invoices"
record = env["account.move"].sudo().browse(record_id)
report = env["ir.actions.report"]._get_report(report_name)
filename = safe_eval(report.print_report_name, {"object": record})
content = (
env["ir.actions.report"].sudo()._render_qweb_pdf(report_name, [record.id])[0]
)
return filename, content
return record._generate_report("account.account_invoices")

0 comments on commit ea8965e

Please sign in to comment.