fix: submit depreciation schedule only for submitted asset

This commit is contained in:
khushi8112
2025-08-05 14:00:27 +05:30
parent 708ba3b229
commit a4628c2024

View File

@@ -86,8 +86,24 @@ class AssetDepreciationSchedule(DepreciationScheduleController):
)
def on_submit(self):
self.validate_asset()
self.db_set("status", "Active")
def validate_asset(self):
asset = frappe.get_doc("Asset", self.asset)
if not asset.calculate_depreciation:
frappe.throw(
_("Asset {0} is not set to calculate depreciation.").format(
get_link_to_form("Asset", self.asset)
)
)
if asset.docstatus != 1:
frappe.throw(
_("Asset {0} is not submitted. Please submit the asset before proceeding.").format(
get_link_to_form("Asset", self.asset)
)
)
def on_cancel(self):
self.db_set("status", "Cancelled")
if not self.flags.should_not_cancel_depreciation_entries: