fix(asset repair): validate pi status

This commit is contained in:
Pugazhendhi Velu
2025-11-17 14:06:26 +00:00
parent 623a0a932e
commit 2db91ee67e

View File

@@ -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"):