From 6afc6818a34151c8f29447226701c9847707bdfa Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 31 Jan 2012 17:21:04 +0530 Subject: [PATCH] Check for duplicate challan number only in submitted purchase receipts --- erpnext/stock/doctype/purchase_receipt/purchase_receipt.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py index 0572592645..41ee2ff3bd 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py @@ -93,11 +93,12 @@ class DocType(TransactionBase): def validate_challan_no(self): - "Validate if same challan no exists for same supplier in a purchase receipt" + "Validate if same challan no exists for same supplier in a submitted purchase receipt" if self.doc.challan_no: exists = webnotes.conn.sql(""" SELECT name FROM `tabPurchase Receipt` - WHERE name!=%s AND supplier=%s AND challan_no=%s""", (self.doc.name, self.doc.supplier, self.doc.challan_no)) + WHERE name!=%s AND supplier=%s AND challan_no=%s + AND docstatus=1""", (self.doc.name, self.doc.supplier, self.doc.challan_no)) if exists: webnotes.msgprint("Another Purchase Receipt using the same Challan No. already exists.\ Please enter a valid Challan No.", raise_exception=1)