Persistent definition of a Fusion financial report. Each report (P&L, balance sheet, trial balance, GL) has one row in fusion.report holding its metadata + line specs (stored as JSON for layout flexibility). V19 conventions: models.Constraint inline, no _sql_constraints. Per- company uniqueness on (company_id, code). 3 new tests, 27 total passing. Made-with: Cursor
45 lines
1.5 KiB
Python
45 lines
1.5 KiB
Python
"""Tests for fusion.report definition model."""
|
|
|
|
from odoo.tests.common import TransactionCase, tagged
|
|
|
|
|
|
@tagged('post_install', '-at_install')
|
|
class TestFusionReport(TransactionCase):
|
|
|
|
def test_create_minimal(self):
|
|
report = self.env['fusion.report'].create({
|
|
'name': 'Test P&L',
|
|
'code': 'test_pnl_minimal',
|
|
'report_type': 'pnl',
|
|
})
|
|
self.assertEqual(report.name, 'Test P&L')
|
|
self.assertTrue(report.active)
|
|
self.assertEqual(report.default_comparison_mode, 'none')
|
|
|
|
def test_line_specs_json_roundtrip(self):
|
|
specs = [
|
|
{'label': 'Revenue', 'account_type_prefix': 'income_', 'sign': 1},
|
|
{'label': 'COGS', 'account_type_prefix': 'expense_direct_', 'sign': -1},
|
|
]
|
|
report = self.env['fusion.report'].create({
|
|
'name': 'Test',
|
|
'code': 'test_json_roundtrip',
|
|
'report_type': 'pnl',
|
|
'line_specs': specs,
|
|
})
|
|
self.assertEqual(report.line_specs, specs)
|
|
self.assertEqual(report.line_specs[0]['label'], 'Revenue')
|
|
|
|
def test_company_code_uniqueness(self):
|
|
self.env['fusion.report'].create({
|
|
'name': 'A',
|
|
'code': 'dup_code_test',
|
|
'report_type': 'pnl',
|
|
})
|
|
with self.assertRaises(Exception):
|
|
self.env['fusion.report'].create({
|
|
'name': 'B',
|
|
'code': 'dup_code_test',
|
|
'report_type': 'pnl',
|
|
})
|