Fixed Asset Depreciation Wizard Documentation¶
Overview¶
The Fixed Asset Depreciation Wizard (account.fixed.asset.depreciation) provides a user-friendly interface for running batch depreciation on all registered assets. This transient model (not stored in database) allows users to specify a depreciation end date and automatically processes all active assets, creating depreciation periods and journal entries.
Model Information¶
Model Name: account.fixed.asset.depreciation
Display Name: Depreciation
Name Field: None
Key Fields: None
Transient: Yes (not persisted to database)
Features¶
- ✅ Batch depreciation processing
- ✅ Auto-default to month-end
- ✅ Processes all registered assets
- ✅ Single-click operation
- ✅ Confirmation flash message
Key Fields Reference¶
Wizard Fields¶
| Field | Type | Required | Description |
|---|---|---|---|
date_to |
Date | ✅ | Depreciation end date |
Default Value: Last day of current month
API Methods¶
1. Update (Run Depreciation)¶
Method: update(ids, context)
Runs depreciation on all registered assets to specified date.
Behavior:
1. Finds all assets with state = "registered"
2. Calls depreciate() on each asset
3. Creates depreciation periods
4. Generates and posts journal entries
5. Returns to asset list with success message
Example:
# Create wizard instance
wizard_id = get_model("account.fixed.asset.depreciation").create({
"date_to": "2025-01-31"
})
# Run depreciation
result = get_model("account.fixed.asset.depreciation").update(
[wizard_id],
context={}
)
# Returns:
# {
# "next": {"name": "fixed_asset", "mode": "list"},
# "flash": "All registered assets are depreciated to 2025-01-31"
# }
Common Use Cases¶
Use Case 1: Monthly Depreciation (End of Month)¶
from datetime import date
from dateutil.relativedelta import relativedelta
# Calculate last day of current month
today = date.today()
month_end = (today + relativedelta(day=31)).strftime("%Y-%m-%d")
# Create and run wizard
wizard_id = get_model("account.fixed.asset.depreciation").create({
"date_to": month_end
})
result = get_model("account.fixed.asset.depreciation").update([wizard_id])
print(f"✓ All assets depreciated to {month_end}")
Use Case 2: Year-End Depreciation¶
# Depreciate all assets to year-end
year_end = "2025-12-31"
wizard_id = get_model("account.fixed.asset.depreciation").create({
"date_to": year_end
})
result = get_model("account.fixed.asset.depreciation").update([wizard_id])
print(f"✓ Year-end depreciation complete")
Use Case 3: Catch-Up Depreciation¶
# Depreciate multiple months at once
# Useful if depreciation wasn't run for several months
wizard_id = get_model("account.fixed.asset.depreciation").create({
"date_to": "2025-06-30" # Catch up to June
})
result = get_model("account.fixed.asset.depreciation").update([wizard_id])
# Creates periods for all missing months
print("✓ Catch-up depreciation complete")
Use Case 4: Scheduled Monthly Depreciation¶
# Automated monthly depreciation job
from datetime import date
from dateutil.relativedelta import relativedelta
def run_monthly_depreciation():
"""
Run on 1st day of each month for previous month
"""
# Get last day of previous month
today = date.today()
first_of_month = today.replace(day=1)
last_month_end = (first_of_month - timedelta(days=1)).strftime("%Y-%m-%d")
# Run depreciation wizard
wizard_id = get_model("account.fixed.asset.depreciation").create({
"date_to": last_month_end
})
result = get_model("account.fixed.asset.depreciation").update([wizard_id])
# Log result
print(f"Automated depreciation completed for {last_month_end}")
return result
# Schedule this to run monthly
Use Case 5: Check Status Before Depreciation¶
# Verify registered assets before running
registered_assets = get_model("account.fixed.asset").search_browse([
["state", "=", "registered"]
])
print(f"Assets to depreciate: {len(registered_assets)}")
print("=" * 80)
for asset in registered_assets[:10]: # Show first 10
last_dep = asset.last_dep or "Never"
print(f"{asset.number:15} {asset.name[:30]:30} Last Dep: {last_dep}")
# Confirm and run
if len(registered_assets) > 0:
wizard_id = get_model("account.fixed.asset.depreciation").create({
"date_to": "2025-01-31"
})
result = get_model("account.fixed.asset.depreciation").update([wizard_id])
print(f"\n✓ Depreciated {len(registered_assets)} assets")
else:
print("\nNo registered assets to depreciate")
Use Case 6: Depreciation with Verification¶
# Run depreciation and verify results
from datetime import datetime
date_to = "2025-01-31"
# Count assets before
assets_before = get_model("account.fixed.asset").search([
["state", "=", "registered"]
])
count_before = len(assets_before)
# Run depreciation
wizard_id = get_model("account.fixed.asset.depreciation").create({
"date_to": date_to
})
result = get_model("account.fixed.asset.depreciation").update([wizard_id])
# Verify periods created
periods_created = get_model("account.fixed.asset.period").search([
["date_to", "=", date_to]
])
print(f"Depreciation Results for {date_to}:")
print(f" Assets processed: {count_before}")
print(f" Periods created: {len(periods_created)}")
# Verify journal entries
moves = get_model("account.move").search_browse([
["date", "=", date_to],
["narration", "=", "Fixed asset depreciation"]
])
print(f" Journal entries: {len(moves)}")
Best Practices¶
1. Run Monthly on Schedule¶
# Best practice: Run depreciation on 1st of each month
# for previous month
# Good: Consistent monthly schedule
# Jan 1: Depreciate to Dec 31
# Feb 1: Depreciate to Jan 31
# Mar 1: Depreciate to Feb 28/29
2. Use Month-End Dates¶
# Good: Use actual month-end dates
wizard = {"date_to": "2025-01-31"} # Last day of January
# Avoid: Mid-month dates (creates partial periods)
wizard = {"date_to": "2025-01-15"} # Splits month
3. Verify Before Running¶
# Check registered assets before depreciation
asset_count = get_model("account.fixed.asset").search([
["state", "=", "registered"]
], count=True)
print(f"Ready to depreciate {asset_count} assets")
# Review and confirm before running
4. Check for Errors¶
# After running, check for issues
try:
wizard_id = get_model("account.fixed.asset.depreciation").create({
"date_to": "2025-01-31"
})
result = get_model("account.fixed.asset.depreciation").update([wizard_id])
print("✓ Depreciation successful")
except Exception as e:
print(f"✗ Depreciation failed: {str(e)}")
# Review asset setup, accounts, etc.
5. Don't Re-Run for Same Period¶
# Wizard is smart - won't duplicate existing periods
# But best practice: Don't run twice for same month
# Check if already depreciated
last_period = get_model("account.fixed.asset.period").search([
["date_to", "=", "2025-01-31"]
], limit=1)
if last_period:
print("⚠ Already depreciated to this date")
else:
# Run depreciation
wizard_id = get_model("account.fixed.asset.depreciation").create({
"date_to": "2025-01-31"
})
result = get_model("account.fixed.asset.depreciation").update([wizard_id])
Workflow Example¶
Complete Monthly Depreciation Workflow¶
from datetime import date, timedelta
from dateutil.relativedelta import relativedelta
def monthly_depreciation_workflow():
"""
Complete workflow for monthly depreciation
"""
# 1. Calculate target date (last day of previous month)
today = date.today()
first_of_month = today.replace(day=1)
target_date = (first_of_month - timedelta(days=1)).strftime("%Y-%m-%d")
print(f"DEPRECIATION WORKFLOW - {target_date}")
print("=" * 60)
# 2. Get registered assets
assets = get_model("account.fixed.asset").search_browse([
["state", "=", "registered"]
])
print(f"Step 1: Found {len(assets)} registered assets")
# 3. Check if already depreciated
existing_periods = get_model("account.fixed.asset.period").search([
["date_to", "=", target_date]
])
if existing_periods:
print(f"Step 2: ⚠ Already have {len(existing_periods)} periods for this date")
return
# 4. Run depreciation
print(f"Step 2: Running depreciation to {target_date}...")
wizard_id = get_model("account.fixed.asset.depreciation").create({
"date_to": target_date
})
result = get_model("account.fixed.asset.depreciation").update([wizard_id])
# 5. Verify results
new_periods = get_model("account.fixed.asset.period").search([
["date_to", "=", target_date]
])
print(f"Step 3: Created {len(new_periods)} depreciation periods")
# 6. Verify journal entries
moves = get_model("account.move").search_browse([
["date", "=", target_date],
["narration", "=", "Fixed asset depreciation"]
])
print(f"Step 4: Created {len(moves)} journal entries")
# 7. Calculate total depreciation
total_dep = sum(p.amount for p in
get_model("account.fixed.asset.period").browse(new_periods))
print(f"Step 5: Total depreciation expense: ${total_dep:,.2f}")
print("=" * 60)
print("✓ Depreciation workflow complete")
# Run workflow
monthly_depreciation_workflow()
Troubleshooting¶
Issue: "General journal not found"¶
Solution:
# Ensure general journal exists in settings
settings = get_model("settings").browse(1)
if not settings.general_journal_id:
# Create or assign general journal
journal_id = get_model("account.journal").search([
["type", "=", "general"]
])[0]
settings.write({"general_journal_id": journal_id})
Issue: No periods created¶
Possible causes: 1. No registered assets 2. Assets already depreciated to target date 3. Purchase date after target date
Verification:
# Check registered assets
assets = get_model("account.fixed.asset").search_browse([
["state", "=", "registered"]
])
for asset in assets:
print(f"{asset.number}: Last dep = {asset.last_dep}")
Related Models¶
| Model | Relationship | Description |
|---|---|---|
account.fixed.asset |
Referenced | Assets to depreciate |
account.fixed.asset.period |
Creates | Depreciation periods |
account.move |
Creates | Journal entries |
settings |
Referenced | General journal setting |
Version History¶
Last Updated: 2025-12-16 Model Version: account_fixed_asset_depreciation.py Framework: Netforce
Additional Resources¶
- Fixed Asset Documentation:
account.fixed.asset - Depreciation Period Documentation:
account.fixed.asset.period - Journal Entry Documentation:
account.move
This documentation is generated for developer onboarding and reference purposes.