chore: refactoring patch
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index ddceb3a..74f866e 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -268,6 +268,7 @@
erpnext.patches.v13_0.reset_corrupt_defaults
erpnext.patches.v13_0.create_accounting_dimensions_for_asset_repair
erpnext.patches.v15_0.delete_taxjar_doctypes
+erpnext.patches.v15_0.create_asset_depreciation_schedules_from_assets
[post_model_sync]
execute:frappe.delete_doc_if_exists('Workspace', 'ERPNext Integrations Settings')
@@ -319,5 +320,4 @@
erpnext.patches.v14_0.update_partial_tds_fields
erpnext.patches.v14_0.create_incoterms_and_migrate_shipment
erpnext.patches.v14_0.setup_clear_repost_logs
-erpnext.patches.v14_0.create_accounting_dimensions_for_payment_request
-erpnext.patches.v15_0.create_asset_depreciation_schedules_from_assets
\ No newline at end of file
+erpnext.patches.v14_0.create_accounting_dimensions_for_payment_request
\ No newline at end of file
diff --git a/erpnext/patches/v15_0/create_asset_depreciation_schedules_from_assets.py b/erpnext/patches/v15_0/create_asset_depreciation_schedules_from_assets.py
index c281b77..1da0534 100644
--- a/erpnext/patches/v15_0/create_asset_depreciation_schedules_from_assets.py
+++ b/erpnext/patches/v15_0/create_asset_depreciation_schedules_from_assets.py
@@ -1,7 +1,13 @@
import frappe
+from erpnext.assets.doctype.asset_depreciation_schedule.asset_depreciation_schedule import (
+ set_draft_asset_depr_schedule_details,
+)
+
def execute():
+ frappe.reload_doc("assets", "doctype", "Asset Depreciation Schedule")
+
assets = get_details_of_draft_or_submitted_depreciable_assets()
for asset in assets:
@@ -10,20 +16,7 @@
for fb_row in finance_book_rows:
asset_depr_schedule_doc = frappe.new_doc("Asset Depreciation Schedule")
- asset_depr_schedule_doc.asset = asset.name
- asset_depr_schedule_doc.finance_book = fb_row.finance_book
- asset_depr_schedule_doc.finance_book_id = fb_row.idx
- asset_depr_schedule_doc.opening_accumulated_depreciation = (
- asset.opening_accumulated_depreciation
- )
- asset_depr_schedule_doc.depreciation_method = fb_row.depreciation_method
- asset_depr_schedule_doc.total_number_of_depreciations = fb_row.total_number_of_depreciations
- asset_depr_schedule_doc.frequency_of_depreciation = fb_row.frequency_of_depreciation
- asset_depr_schedule_doc.rate_of_depreciation = fb_row.rate_of_depreciation
- asset_depr_schedule_doc.expected_value_after_useful_life = (
- fb_row.expected_value_after_useful_life
- )
- asset_depr_schedule_doc.status = "Draft"
+ set_draft_asset_depr_schedule_details(asset_depr_schedule_doc, asset, fb_row)
asset_depr_schedule_doc.insert()