Fix potential crash in payment_entry.py (#15411)
The new code for cost center checking in payment_entry.py crashes if `voucher_type` is `None`, which is an explicit possibility if party type is Employee. This commit adds a simple check to make sure that voucher_type is not None before running `get_doc`.
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py
index 6c814ad..6a361a4 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.py
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py
@@ -589,10 +589,11 @@
voucher_type = None
# Add cost center condition
- doc = frappe.get_doc({"doctype": voucher_type})
- condition = ""
- if doc and hasattr(doc, 'cost_center'):
- condition = " and cost_center='%s'" % cost_center
+ if voucher_type:
+ doc = frappe.get_doc({"doctype": voucher_type})
+ condition = ""
+ if doc and hasattr(doc, 'cost_center'):
+ condition = " and cost_center='%s'" % cost_center
orders = []
if voucher_type: