feat(fusion_accounting_assets): disposal wizard
Made-with: Cursor
This commit is contained in:
@@ -20,3 +20,4 @@ from . import test_method_integration
|
||||
from . import test_asset_book_values_mv
|
||||
from . import test_performance_benchmarks
|
||||
from . import test_create_asset_wizard
|
||||
from . import test_disposal_wizard
|
||||
|
||||
50
fusion_accounting_assets/tests/test_disposal_wizard.py
Normal file
50
fusion_accounting_assets/tests/test_disposal_wizard.py
Normal file
@@ -0,0 +1,50 @@
|
||||
from datetime import date
|
||||
|
||||
from odoo.tests import tagged
|
||||
from odoo.tests.common import TransactionCase
|
||||
|
||||
|
||||
@tagged('post_install', '-at_install')
|
||||
class TestDisposalWizard(TransactionCase):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.asset = self.env['fusion.asset'].create({
|
||||
'name': 'Disposal Test Asset',
|
||||
'cost': 6000,
|
||||
'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(self.asset)
|
||||
self.asset.action_set_running()
|
||||
|
||||
def test_default_loads_active_asset(self):
|
||||
wizard = self.env['fusion.disposal.wizard'].with_context(
|
||||
active_model='fusion.asset', active_id=self.asset.id,
|
||||
).create({})
|
||||
self.assertEqual(wizard.asset_id, self.asset)
|
||||
|
||||
def test_action_dispose_marks_asset_disposed(self):
|
||||
wizard = self.env['fusion.disposal.wizard'].create({
|
||||
'asset_id': self.asset.id,
|
||||
'disposal_type': 'sale',
|
||||
'sale_amount': 4000,
|
||||
'disposal_date': date(2026, 6, 1),
|
||||
})
|
||||
wizard.action_dispose()
|
||||
self.asset.invalidate_recordset(['state'])
|
||||
self.assertEqual(self.asset.state, 'disposed')
|
||||
|
||||
def test_compute_gain_loss_sale(self):
|
||||
wizard = self.env['fusion.disposal.wizard'].create({
|
||||
'asset_id': self.asset.id,
|
||||
'disposal_type': 'sale',
|
||||
'sale_amount': 7000,
|
||||
})
|
||||
wizard._compute_gain_loss()
|
||||
self.assertAlmostEqual(
|
||||
wizard.estimated_gain_loss,
|
||||
7000 - self.asset.book_value,
|
||||
places=2,
|
||||
)
|
||||
Reference in New Issue
Block a user