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`.
This commit is contained in:
theopen-institute 2018-09-17 11:14:39 +05:45 committed by Nabin Hait
parent e79e4cb9b1
commit ba1c0c900d

View File

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