44 lines
1.7 KiB
Python
44 lines
1.7 KiB
Python
from datetime import date
|
|
|
|
from odoo.tests import tagged
|
|
from odoo.tests.common import TransactionCase
|
|
|
|
|
|
@tagged('post_install', '-at_install')
|
|
class TestDepreciationRunWizard(TransactionCase):
|
|
|
|
def test_run_all_running_posts_due_periods(self):
|
|
for amt in [3000, 5000]:
|
|
asset = self.env['fusion.asset'].create({
|
|
'name': f'Run Test {amt}', 'cost': amt,
|
|
'acquisition_date': date(2026, 1, 1),
|
|
'in_service_date': date(2026, 1, 1),
|
|
'method': 'straight_line', 'useful_life_years': 3,
|
|
})
|
|
self.env['fusion.asset.engine'].compute_depreciation_schedule(asset)
|
|
asset.action_set_running()
|
|
wizard = self.env['fusion.depreciation.run.wizard'].create({
|
|
'period_date': date(2030, 12, 31),
|
|
'state_filter': 'all_running',
|
|
})
|
|
wizard.action_run()
|
|
self.assertEqual(wizard.state, 'done')
|
|
self.assertGreater(wizard.posted_count, 0)
|
|
|
|
def test_run_selected_posts_only_selected(self):
|
|
asset = self.env['fusion.asset'].create({
|
|
'name': 'Selected Test', 'cost': 1000,
|
|
'acquisition_date': date(2026, 1, 1),
|
|
'in_service_date': date(2026, 1, 1),
|
|
'method': 'straight_line', 'useful_life_years': 3,
|
|
})
|
|
self.env['fusion.asset.engine'].compute_depreciation_schedule(asset)
|
|
asset.action_set_running()
|
|
wizard = self.env['fusion.depreciation.run.wizard'].create({
|
|
'period_date': date(2030, 12, 31),
|
|
'state_filter': 'selected',
|
|
'asset_ids': [(6, 0, [asset.id])],
|
|
})
|
|
wizard.action_run()
|
|
self.assertEqual(wizard.state, 'done')
|