From 7a86a77322122efa0565f00d21fb6a8f46a1158e Mon Sep 17 00:00:00 2001 From: Kevin Chan Date: Mon, 12 Oct 2020 11:30:36 +0800 Subject: [PATCH] fix: Asset status after maintenance or repair Fix a bug where an **Asset**'s status is not being set to what it was previously after an **Asset Repair** or **Asset Maintenance**. --- erpnext/assets/doctype/asset/asset.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/erpnext/assets/doctype/asset/asset.py b/erpnext/assets/doctype/asset/asset.py index efdbdb1fbf..45fdc9316e 100644 --- a/erpnext/assets/doctype/asset/asset.py +++ b/erpnext/assets/doctype/asset/asset.py @@ -131,7 +131,7 @@ class Asset(AccountsController): def validate_gross_and_purchase_amount(self): if self.is_existing_asset: return - + if self.gross_purchase_amount and self.gross_purchase_amount != self.purchase_receipt_amount: frappe.throw(_("Gross Purchase Amount should be {} to purchase amount of one single Asset. {}\ Please do not book expense of multiple assets against one single Asset.") @@ -561,14 +561,18 @@ class Asset(AccountsController): return 100 * (1 - flt(depreciation_rate, float_precision)) def update_maintenance_status(): - assets = frappe.get_all('Asset', filters = {'docstatus': 1, 'maintenance_required': 1}) + assets = frappe.get_all( + "Asset", filters={"docstatus": 1, "maintenance_required": 1} + ) for asset in assets: asset = frappe.get_doc("Asset", asset.name) - if frappe.db.exists('Asset Maintenance Task', {'parent': asset.name, 'next_due_date': today()}): - asset.set_status('In Maintenance') - if frappe.db.exists('Asset Repair', {'asset_name': asset.name, 'repair_status': 'Pending'}): - asset.set_status('Out of Order') + if frappe.db.exists("Asset Repair", {"asset_name": asset.name, "repair_status": "Pending"}): + asset.set_status("Out of Order") + elif frappe.db.exists("Asset Maintenance Task", {"parent": asset.name, "next_due_date": today()}): + asset.set_status("In Maintenance") + else: + asset.set_status() def make_post_gl_entry():