From 66e6f01e40a0f9eaf6242d4eec7e97bc410e830f Mon Sep 17 00:00:00 2001 From: GangaManoj Date: Thu, 13 May 2021 23:17:17 +0530 Subject: [PATCH] fix(Asset Repair): Make Purchase Invoice mandatory if capitalize_repair_cost is checked --- erpnext/assets/doctype/asset_repair/asset_repair.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/erpnext/assets/doctype/asset_repair/asset_repair.py b/erpnext/assets/doctype/asset_repair/asset_repair.py index 8ff3b796d20..2807c0f5bd6 100644 --- a/erpnext/assets/doctype/asset_repair/asset_repair.py +++ b/erpnext/assets/doctype/asset_repair/asset_repair.py @@ -41,10 +41,13 @@ class AssetRepair(Document): self.check_for_payable_account() self.check_for_cost_center() - self.increase_asset_value() + if self.stock_consumption or self.capitalize_repair_cost: + self.increase_asset_value() if self.stock_consumption: self.check_for_stock_items_and_warehouse() self.decrease_stock_quantity() + if self.capitalize_repair_cost: + self.check_for_purchase_invoice() self.make_gl_entries() def check_repair_status(self): @@ -90,6 +93,10 @@ class AssetRepair(Document): stock_entry.insert() stock_entry.submit() + def check_for_purchase_invoice(self): + if not self.purchase_invoice: + frappe.throw(_("Please link Purchase Invoice.")) + def on_cancel(self): if self.payable_account: self.make_gl_entries(cancel=True)