feat(fusion_accounting_reports): fusion.report.anomaly persisted model

Made-with: Cursor
This commit is contained in:
gsinghpal
2026-04-19 15:32:09 -04:00
parent 22b277c6b8
commit c20e0888e1
6 changed files with 112 additions and 1 deletions

View File

@@ -9,3 +9,4 @@ from . import test_anomaly_detection
from . import test_commentary_prompt
from . import test_commentary_generator
from . import test_fusion_report_commentary
from . import test_fusion_report_anomaly

View File

@@ -0,0 +1,52 @@
"""Tests for fusion.report.anomaly model."""
from datetime import date
from odoo.tests.common import TransactionCase, tagged
@tagged('post_install', '-at_install')
class TestFusionReportAnomaly(TransactionCase):
def setUp(self):
super().setUp()
self.report = self.env.ref('fusion_accounting_reports.report_pnl')
def _make(self, **vals):
defaults = {
'report_id': self.report.id,
'period_from': date(2026, 4, 1),
'period_to': date(2026, 4, 30),
'row_id': 'line_0',
'label': 'Revenue',
'current_amount': 12000,
'comparison_amount': 10000,
'variance_amount': 2000,
'variance_pct': 20.0,
'severity': 'medium',
'direction': 'increase',
}
defaults.update(vals)
return self.env['fusion.report.anomaly'].create(defaults)
def test_create_basic(self):
a = self._make()
self.assertEqual(a.severity, 'medium')
self.assertEqual(a.state, 'new')
self.assertTrue(a.detected_at)
def test_acknowledge_action(self):
a = self._make()
a.action_acknowledge()
self.assertEqual(a.state, 'acknowledged')
self.assertEqual(a.acknowledged_by, self.env.user)
self.assertTrue(a.acknowledged_at)
def test_dismiss_action(self):
a = self._make()
a.action_dismiss()
self.assertEqual(a.state, 'dismissed')
def test_resolve_action(self):
a = self._make()
a.action_resolve()
self.assertEqual(a.state, 'resolved')