mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-02 03:39:11 +00:00
fix: submit depreciation schedule only for submitted asset
This commit is contained in:
@@ -86,8 +86,24 @@ class AssetDepreciationSchedule(DepreciationScheduleController):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
|
self.validate_asset()
|
||||||
self.db_set("status", "Active")
|
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):
|
def on_cancel(self):
|
||||||
self.db_set("status", "Cancelled")
|
self.db_set("status", "Cancelled")
|
||||||
if not self.flags.should_not_cancel_depreciation_entries:
|
if not self.flags.should_not_cancel_depreciation_entries:
|
||||||
|
|||||||
Reference in New Issue
Block a user