This commit is contained in:
2026-11-08 17:43:44 +08:00
parent 974a1fb10b
commit 3b5af1e3a6
483 changed files with 590466 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
from unittest.mock import patch
from odoo.tests import tagged
from odoo.tests.common import freeze_time
from odoo.addons.account_reports.tests.common import TestAccountReportsCommon
@freeze_time('2024-01-01')
@tagged('post_install', '-at_install')
class TestKpiProvider(TestAccountReportsCommon):
_test_user_groups = None # FIXME list needed groups
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.company.write({
'vat': '38972223422',
'phone': '555-555-5555',
'email': 'test@example.com'
})
# The kpi are fetched for all companies, disregarding any access rules. We need to make sure no other company in the database
# contains return types that could interfere with the test.
cls.env['account.return'].sudo().search([]).active = False
cls.return_types = cls.env['account.return.type'].create([
{'name': 'Return with a report without a root report',
'report_id': cls.env.ref('account.generic_tax_report').id,
'deadline_start_date': '2024-01-01'},
{'name': 'Return with a root report',
'report_id': cls.env.ref('account_reports.followup_report').id,
'deadline_start_date': '2024-01-01'},
{'name': 'Return without a report',
'deadline_start_date': '2024-01-01'},
])
def generate_all_returns(account_return_type, country_code, main_company, tax_unit=None, return_types=None):
for return_type in cls.return_types:
return_type._try_create_returns_for_fiscal_year(main_company, tax_unit)
with patch.object(cls.registry['account.return.type'], '_generate_all_returns', generate_all_returns):
cls.env.company.account_opening_date = '2024-01-01'
def test_kpi_summary(self):
self.assertCountEqual(self.env['kpi.provider'].get_account_reports_kpi_summary(), [
{'id': 'account_return.account_generic_tax_report',
'name': 'Generic Tax report',
'type': 'return_status',
'value': 'to_do'},
{'id': 'account_return.account_reports_followup_report',
'name': 'Open Items',
'type': 'return_status',
'value': 'to_do'},
{'id': 'account_return.return_without_a_report',
'name': 'Return without a report',
'type': 'return_status',
'value': 'to_do'},
])