diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index 1f9747a77cb..1c91b9ef8e3 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -1994,7 +1994,7 @@ class PaymentEntry(AccountsController): # Re allocate amount to those references which have PR set (Higher priority) for ref in self.references: - if not ref.payment_request: + if not (ref.reference_doctype and ref.reference_name and ref.payment_request): continue # fetch outstanding_amount of `Reference` (Payment Term) and `Payment Request` to allocate new amount @@ -2045,7 +2045,7 @@ class PaymentEntry(AccountsController): ) # Re allocate amount to those references which have no PR (Lower priority) for ref in self.references: - if ref.payment_request: + if ref.payment_request or not (ref.reference_doctype and ref.reference_name): continue key = (ref.reference_doctype, ref.reference_name, ref.get("payment_term"))