fix(Asset Repair): Make Purchase Invoice mandatory if capitalize_repair_cost is checked
diff --git a/erpnext/assets/doctype/asset_repair/asset_repair.py b/erpnext/assets/doctype/asset_repair/asset_repair.py
index 8ff3b79..2807c0f 100644
--- a/erpnext/assets/doctype/asset_repair/asset_repair.py
+++ b/erpnext/assets/doctype/asset_repair/asset_repair.py
@@ -41,10 +41,13 @@
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 @@
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)