From 9f7098115b58ac8e2b06885727d3adea02239425 Mon Sep 17 00:00:00 2001 From: deepeshgarg007 Date: Mon, 19 Aug 2019 17:53:47 +0530 Subject: [PATCH 1/2] fix: Failing sales and purchase return test cases --- erpnext/controllers/sales_and_purchase_return.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/erpnext/controllers/sales_and_purchase_return.py b/erpnext/controllers/sales_and_purchase_return.py index 28dd4ea8b6f..611a1fceadd 100644 --- a/erpnext/controllers/sales_and_purchase_return.py +++ b/erpnext/controllers/sales_and_purchase_return.py @@ -24,7 +24,9 @@ def validate_return_against(doc): 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") From f1618af76c3ee18918e0ccbd3b17a8b0fe0b2a68 Mon Sep 17 00:00:00 2001 From: deepeshgarg007 Date: Mon, 19 Aug 2019 18:53:11 +0530 Subject: [PATCH 2/2] fix: Syntax error --- erpnext/controllers/sales_and_purchase_return.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/controllers/sales_and_purchase_return.py b/erpnext/controllers/sales_and_purchase_return.py index 611a1fceadd..b713958b1b8 100644 --- a/erpnext/controllers/sales_and_purchase_return.py +++ b/erpnext/controllers/sales_and_purchase_return.py @@ -26,7 +26,7 @@ def validate_return_against(doc): 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:: + 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")