fix(Asset Repair): Add mandatory_depends_on condition for Purchase Invoice
diff --git a/erpnext/assets/doctype/asset_repair/asset_repair.json b/erpnext/assets/doctype/asset_repair/asset_repair.json
index 840589c..d3335c5 100644
--- a/erpnext/assets/doctype/asset_repair/asset_repair.json
+++ b/erpnext/assets/doctype/asset_repair/asset_repair.json
@@ -241,6 +241,7 @@
"fieldname": "purchase_invoice",
"fieldtype": "Link",
"label": "Purchase Invoice",
+ "mandatory_depends_on": "eval: doc.repair_status == 'Completed' && doc.repair_cost > 0",
"options": "Purchase Invoice"
},
{
@@ -254,7 +255,7 @@
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
- "modified": "2021-06-16 08:02:34.782990",
+ "modified": "2021-06-16 08:16:07.581813",
"modified_by": "Administrator",
"module": "Assets",
"name": "Asset Repair",
diff --git a/erpnext/assets/doctype/asset_repair/asset_repair.py b/erpnext/assets/doctype/asset_repair/asset_repair.py
index bd5e462..01eeb36 100644
--- a/erpnext/assets/doctype/asset_repair/asset_repair.py
+++ b/erpnext/assets/doctype/asset_repair/asset_repair.py
@@ -45,7 +45,6 @@
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()
if frappe.db.get_value('Asset', self.asset, 'calculate_depreciation'):
self.modify_depreciation_schedule()
@@ -90,10 +89,6 @@
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):
self.make_gl_entries(cancel=True)