From ba1c0c900d5d827ae39c77cea2d29edb5541e6ae Mon Sep 17 00:00:00 2001 From: theopen-institute Date: Mon, 17 Sep 2018 11:14:39 +0545 Subject: [PATCH] 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`. --- erpnext/accounts/doctype/payment_entry/payment_entry.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index 6c814ad954..6a361a4bfa 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -589,10 +589,11 @@ def get_orders_to_be_billed(posting_date, party_type, party, party_account_curre 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: