diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index 5830246bca9..936b9bcbbd4 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -1590,7 +1590,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 @@ -1641,7 +1641,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"))