From 0549b1c5c96ecefd0a5a3fde03417fcbc5dca7e2 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 21 Apr 2014 15:59:47 +0530 Subject: [PATCH] Duplicate supplier delivery number validation in Purchase Receipt should happen per financial year --- erpnext/stock/doctype/purchase_receipt/purchase_receipt.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py index f9c70ee581..f9ea084ada 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py @@ -92,10 +92,9 @@ class PurchaseReceipt(BuyingController): def validate_challan_no(self): "Validate if same challan no exists for same supplier in a submitted purchase receipt" if self.challan_no: - exists = frappe.db.sql_list(""" - SELECT name FROM `tabPurchase Receipt` - WHERE name!=%s AND supplier=%s AND challan_no=%s - AND docstatus=1""", (self.name, self.supplier, self.challan_no)) + exists = frappe.db.sql_list("""select name from `tabPurchase Receipt` + where docstatus=1 and name!=%s and supplier=%s and challan_no=%s + and fiscal_year=%s""", (self.name, self.supplier, self.challan_no, self.doc.fiscal_year)) if exists: frappe.throw(_("Supplier delivery number duplicate in {0}").format(exists))