feat(fusion_accounting_assets): asset category template model

- defaults applied to new assets (method, useful_life, declining rate,
  salvage %, prorate convention)
- GL account hooks: asset_account_id, depreciation_account_id,
  expense_account_id (domain-filtered to relevant account types)
- computed asset_count for kanban / list views
- 3 new tests (55 total)

Made-with: Cursor
This commit is contained in:
gsinghpal
2026-04-19 16:57:25 -04:00
parent 0439d81675
commit b68d1b1c66
4 changed files with 80 additions and 7 deletions

View File

@@ -5,3 +5,4 @@ from . import test_asset_anomaly_detection
from . import test_useful_life_predictor
from . import test_fusion_asset
from . import test_fusion_asset_depreciation_line
from . import test_fusion_asset_category

View File

@@ -0,0 +1,35 @@
from datetime import date
from odoo.tests.common import TransactionCase
from odoo.tests import tagged
@tagged('post_install', '-at_install')
class TestFusionAssetCategory(TransactionCase):
def test_create_with_defaults(self):
cat = self.env['fusion.asset.category'].create({'name': 'Computers'})
self.assertEqual(cat.method, 'straight_line')
self.assertEqual(cat.useful_life_years, 5)
self.assertEqual(cat.prorate_convention, 'days_period')
self.assertEqual(cat.asset_count, 0)
def test_asset_count_reflects_linked_assets(self):
cat = self.env['fusion.asset.category'].create({'name': 'Vehicles'})
for i in range(3):
self.env['fusion.asset'].create({
'name': f'Truck {i}',
'cost': 50000,
'acquisition_date': date(2026, 1, 1),
'method': 'declining_balance',
'category_id': cat.id,
})
cat.invalidate_recordset(['asset_count'])
self.assertEqual(cat.asset_count, 3)
def test_method_must_be_in_selection(self):
with self.assertRaises(Exception):
self.env['fusion.asset.category'].create({
'name': 'Bogus',
'method': 'not_a_method',
})