feat(fusion_accounting_reports): fusion.report.commentary cache model

Made-with: Cursor
This commit is contained in:
gsinghpal
2026-04-19 15:31:22 -04:00
parent 17053b1603
commit 22b277c6b8
6 changed files with 100 additions and 1 deletions

View File

@@ -8,3 +8,4 @@ from . import test_seeded_reports
from . import test_anomaly_detection
from . import test_commentary_prompt
from . import test_commentary_generator
from . import test_fusion_report_commentary

View File

@@ -0,0 +1,53 @@
"""Tests for fusion.report.commentary cache model."""
from datetime import date
from odoo.tests.common import TransactionCase, tagged
@tagged('post_install', '-at_install')
class TestFusionReportCommentary(TransactionCase):
def setUp(self):
super().setUp()
self.report = self.env.ref('fusion_accounting_reports.report_pnl')
def test_create_minimal(self):
c = self.env['fusion.report.commentary'].create({
'report_id': self.report.id,
'period_from': date(2026, 4, 1),
'period_to': date(2026, 4, 30),
'summary': 'Test summary.',
'highlights': ['point 1', 'point 2'],
})
self.assertEqual(c.summary, 'Test summary.')
self.assertEqual(c.highlights, ['point 1', 'point 2'])
self.assertEqual(c.generated_by, 'on_demand')
def test_uniqueness_per_period(self):
self.env['fusion.report.commentary'].create({
'report_id': self.report.id,
'period_from': date(2026, 4, 1),
'period_to': date(2026, 4, 30),
'comparison_mode': 'none',
})
with self.assertRaises(Exception):
self.env['fusion.report.commentary'].create({
'report_id': self.report.id,
'period_from': date(2026, 4, 1),
'period_to': date(2026, 4, 30),
'comparison_mode': 'none',
})
def test_different_comparison_modes_can_coexist(self):
for mode in ['none', 'previous_period', 'previous_year']:
self.env['fusion.report.commentary'].create({
'report_id': self.report.id,
'period_from': date(2026, 5, 1),
'period_to': date(2026, 5, 31),
'comparison_mode': mode,
})
count = self.env['fusion.report.commentary'].search_count([
('report_id', '=', self.report.id),
('period_from', '=', date(2026, 5, 1)),
])
self.assertEqual(count, 3)