From 40847aeac3c5a138dc422d4996979f8a04c0e74a Mon Sep 17 00:00:00 2001 From: Saqib Date: Thu, 25 Jun 2020 15:43:31 +0530 Subject: [PATCH] fix: cannot cancel assets with repair pending (#22440) * fix: cannot cancel assets with repair pending * fix: message * Update asset.py Co-authored-by: Nabin Hait --- erpnext/assets/doctype/asset/asset.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/erpnext/assets/doctype/asset/asset.py b/erpnext/assets/doctype/asset/asset.py index 2ecabe60f0..9ae5a87e6b 100644 --- a/erpnext/assets/doctype/asset/asset.py +++ b/erpnext/assets/doctype/asset/asset.py @@ -408,6 +408,8 @@ class Asset(AccountsController): row.expected_value_after_useful_life = asset_value_after_full_schedule def validate_cancellation(self): + if self.status in ("In Maintenance", "Out of Order"): + frappe.throw(_("There are active maintenance or repairs against the asset. You must complete all of them before cancelling the asset.")) if self.status not in ("Submitted", "Partially Depreciated", "Fully Depreciated"): frappe.throw(_("Asset cannot be cancelled, as it is already {0}").format(self.status))