Adds an AbstractModel report (report_pdf.py) and a single multi-purpose QWeb template (report_pdf_template.xml) that renders P&L, Balance Sheet, Trial Balance, and General Ledger results from the engine. Wires the controller's /fusion/reports/export_pdf endpoint to actually return base64-encoded PDF bytes via _render_qweb_pdf. The template walks the result['rows'] list and applies indentation/bold based on level and is_subtotal flags, with optional comparison columns when present. Tests: 2 new (test_pdf_export.py) + 1 controller test updated to assert the real PDF response. Net 109 -> 111. Made-with: Cursor
35 lines
1.3 KiB
Python
35 lines
1.3 KiB
Python
"""Tests for the PDF export."""
|
|
|
|
from odoo.tests.common import TransactionCase, tagged
|
|
|
|
|
|
@tagged('post_install', '-at_install')
|
|
class TestPdfExport(TransactionCase):
|
|
|
|
def test_pdf_render_pnl(self):
|
|
report = self.env.ref('fusion_accounting_reports.report_pnl')
|
|
pdf, content_type = self.env['ir.actions.report'].sudo()._render_qweb_pdf(
|
|
'fusion_accounting_reports.report_pdf_template',
|
|
res_ids=[report.id],
|
|
data={
|
|
'report_type': 'pnl',
|
|
'date_from': '2026-01-01', 'date_to': '2026-12-31',
|
|
'company_id': self.env.company.id,
|
|
},
|
|
)
|
|
self.assertGreater(len(pdf), 500)
|
|
self.assertIn(content_type, ('pdf', 'html'))
|
|
|
|
def test_pdf_render_balance_sheet(self):
|
|
report = self.env.ref('fusion_accounting_reports.report_balance_sheet')
|
|
pdf, _ = self.env['ir.actions.report'].sudo()._render_qweb_pdf(
|
|
'fusion_accounting_reports.report_pdf_template',
|
|
res_ids=[report.id],
|
|
data={
|
|
'report_type': 'balance_sheet',
|
|
'date_from': '2026-01-01', 'date_to': '2026-12-31',
|
|
'company_id': self.env.company.id,
|
|
},
|
|
)
|
|
self.assertGreater(len(pdf), 500)
|