chore: handle some error cases and add empty patch file

This commit is contained in:
anandbaburajan 2022-12-14 13:20:37 +05:30
parent 8534390627
commit c99cd74a15
3 changed files with 19 additions and 3 deletions

View File

@ -113,9 +113,9 @@ def convert_draft_asset_depr_schedules_into_active(asset_doc):
for row in asset_doc.get("finance_books"):
asset_depr_schedule_doc = get_asset_depr_schedule_doc(asset_doc.name, row.finance_book)
asset_depr_schedule_doc.status = "Active"
asset_depr_schedule_doc.submit()
if asset_depr_schedule_doc.status == "Draft":
asset_depr_schedule_doc.status = "Active"
asset_depr_schedule_doc.submit()
def make_new_active_asset_depr_schedules_and_cancel_current_ones(
@ -124,6 +124,13 @@ def make_new_active_asset_depr_schedules_and_cancel_current_ones(
for row in asset_doc.get("finance_books"):
current_asset_depr_schedule_doc = get_asset_depr_schedule_doc(asset_doc.name, row.finance_book)
if not current_asset_depr_schedule_doc:
frappe.throw(
_("Asset Depreciation Schedule not found for Asset {0} and Finance Book {1}").format(
asset_doc.name, row.finance_book
)
)
new_asset_depr_schedule_doc = frappe.copy_doc(current_asset_depr_schedule_doc)
make_depr_schedule(new_asset_depr_schedule_doc, asset_doc, row, date_of_disposal)
@ -157,6 +164,9 @@ def cancel_asset_depr_schedules(asset_doc):
for row in asset_doc.get("finance_books"):
asset_depr_schedule_doc = get_asset_depr_schedule_doc(asset_doc.name, row.finance_book)
if not asset_depr_schedule_doc:
continue
asset_depr_schedule_doc.status = "Cancelled"
asset_depr_schedule_doc.cancel()

View File

@ -268,6 +268,7 @@ erpnext.patches.v13_0.show_hr_payroll_deprecation_warning
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')

View File

@ -0,0 +1,5 @@
# import frappe
def execute():
pass