Merge pull request #18737 from Mangesh-Khairnar/fix-payment-order
fix: restrict the payment order to non received type payment entries
diff --git a/erpnext/controllers/sales_and_purchase_return.py b/erpnext/controllers/sales_and_purchase_return.py
index 28dd4ea..b713958 100644
--- a/erpnext/controllers/sales_and_purchase_return.py
+++ b/erpnext/controllers/sales_and_purchase_return.py
@@ -24,7 +24,9 @@
else:
ref_doc = frappe.get_doc(doc.doctype, doc.return_against)
- if ref_doc.company == doc.company and ref_doc.customer == doc.customer and ref_doc.docstatus == 1:
+ party_type = "customer" if doc.doctype in ("Sales Invoice", "Delivery Note") else "supplier"
+
+ if ref_doc.company == doc.company and ref_doc.get(party_type) == doc.get(party_type) and ref_doc.docstatus == 1:
# validate posting date time
return_posting_datetime = "%s %s" % (doc.posting_date, doc.get("posting_time") or "00:00:00")
ref_posting_datetime = "%s %s" % (ref_doc.posting_date, ref_doc.get("posting_time") or "00:00:00")