feat(fusion_accounting_reports): period picker wizard with common presets
Adds fusion.period.picker.wizard - a guided entry point that lets users pick a report type and a common period preset (this/last month, quarter, YTD, last year, or custom range). The wizard uses the existing date_periods service helpers (month_bounds, quarter_bounds, fiscal_year_bounds) to pre-fill date_from / date_to via @api.onchange. action_open_report returns a client action that launches the OWL reports viewer with default_report_type / default_date_from / default_date_to / default_comparison in the context. Tests: 3 new (test_period_picker.py). Net 111 -> 114. Made-with: Cursor
This commit is contained in:
@@ -20,3 +20,4 @@ from . import test_account_balance_mv
|
||||
from . import test_cron
|
||||
from . import test_pdf_export
|
||||
from . import test_xlsx_export
|
||||
from . import test_period_picker
|
||||
|
||||
36
fusion_accounting_reports/tests/test_period_picker.py
Normal file
36
fusion_accounting_reports/tests/test_period_picker.py
Normal file
@@ -0,0 +1,36 @@
|
||||
"""Tests for period picker wizard."""
|
||||
|
||||
from odoo.tests.common import TransactionCase, tagged
|
||||
|
||||
|
||||
@tagged('post_install', '-at_install')
|
||||
class TestPeriodPickerWizard(TransactionCase):
|
||||
|
||||
def test_this_month_preset_fills_dates(self):
|
||||
wizard = self.env['fusion.period.picker.wizard'].create({
|
||||
'report_type': 'pnl',
|
||||
'period_preset': 'this_month',
|
||||
})
|
||||
wizard._onchange_period_preset()
|
||||
self.assertTrue(wizard.date_from)
|
||||
self.assertTrue(wizard.date_to)
|
||||
self.assertEqual(wizard.date_from.day, 1)
|
||||
|
||||
def test_this_year_preset_uses_ytd(self):
|
||||
wizard = self.env['fusion.period.picker.wizard'].create({
|
||||
'report_type': 'pnl',
|
||||
'period_preset': 'this_year',
|
||||
})
|
||||
wizard._onchange_period_preset()
|
||||
self.assertEqual(wizard.date_from.month, 1)
|
||||
self.assertEqual(wizard.date_from.day, 1)
|
||||
|
||||
def test_action_open_report_returns_client_action(self):
|
||||
wizard = self.env['fusion.period.picker.wizard'].create({
|
||||
'report_type': 'pnl',
|
||||
'period_preset': 'this_year',
|
||||
})
|
||||
wizard._onchange_period_preset()
|
||||
action = wizard.action_open_report()
|
||||
self.assertEqual(action['type'], 'ir.actions.client')
|
||||
self.assertEqual(action['tag'], 'fusion_reports')
|
||||
Reference in New Issue
Block a user