feat(fusion_accounting_reports): fusion.report definition model
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
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
from . import test_services_unit
|
||||
from . import test_currency_conversion
|
||||
from . import test_fusion_report
|
||||
|
||||
44
fusion_accounting_reports/tests/test_fusion_report.py
Normal file
44
fusion_accounting_reports/tests/test_fusion_report.py
Normal file
@@ -0,0 +1,44 @@
|
||||
"""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',
|
||||
})
|
||||
Reference in New Issue
Block a user