feat(fusion_accounting_reports): PDF export with QWeb template

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
This commit is contained in:
gsinghpal
2026-04-19 16:13:22 -04:00
parent d1661f3a33
commit 23b988c401
9 changed files with 191 additions and 5 deletions

View File

@@ -101,13 +101,15 @@ class TestReportsController(HttpCase):
self.assertIn('highlights', result)
self.assertIn('concerns', result)
def test_export_pdf_placeholder(self):
def test_export_pdf_returns_pdf(self):
result = self._jsonrpc('export_pdf', {
'report_type': 'pnl',
'date_from': '2026-01-01',
'date_to': '2026-12-31',
})
self.assertEqual(result.get('status'), 'not_implemented')
self.assertEqual(result.get('status'), 'ok')
self.assertIn('pdf_base64', result)
self.assertTrue(result.get('filename', '').endswith('.pdf'))
def test_export_xlsx_placeholder(self):
result = self._jsonrpc('export_xlsx', {