From 2db91ee67efe95f97528277636245d124eb275cc Mon Sep 17 00:00:00 2001 From: Pugazhendhi Velu Date: Mon, 17 Nov 2025 14:06:26 +0000 Subject: [PATCH] fix(asset repair): validate pi status --- erpnext/assets/doctype/asset_repair/asset_repair.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/erpnext/assets/doctype/asset_repair/asset_repair.py b/erpnext/assets/doctype/asset_repair/asset_repair.py index 358945edf87..77e191873a5 100644 --- a/erpnext/assets/doctype/asset_repair/asset_repair.py +++ b/erpnext/assets/doctype/asset_repair/asset_repair.py @@ -60,6 +60,17 @@ class AssetRepair(AccountsController): if self.get("stock_items"): self.set_stock_items_cost() self.calculate_total_repair_cost() + self.validate_purchase_invoice_status() + + def validate_purchase_invoice_status(self): + if self.purchase_invoice: + docstatus = frappe.db.get_value("Purchase Invoice", self.purchase_invoice, "docstatus") + if docstatus == 0: + frappe.throw( + _("{0} is still in Draft. Please submit it before saving the Asset Repair.").format( + get_link_to_form("Purchase Invoice", self.purchase_invoice) + ) + ) def validate_asset(self): if self.asset_doc.status in ("Sold", "Fully Depreciated", "Scrapped"):