From 2e560cb25dfe1dffc616a18bc840bbac0188273f Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Tue, 27 Mar 2018 11:24:50 +0530 Subject: [PATCH] [Fix] Same serial no returned two times (#13378) --- erpnext/stock/doctype/serial_no/serial_no.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/erpnext/stock/doctype/serial_no/serial_no.py b/erpnext/stock/doctype/serial_no/serial_no.py index 00a8a9305b..233a45c64e 100644 --- a/erpnext/stock/doctype/serial_no/serial_no.py +++ b/erpnext/stock/doctype/serial_no/serial_no.py @@ -217,6 +217,12 @@ def validate_serial_no(sle, item_det): frappe.throw(_("Serial No {0} has already been received").format(serial_no), SerialNoDuplicateError) + if (sr.delivery_document_no and sle.voucher_type != 'Stock Entry' + and sle.voucher_type == sr.delivery_document_type): + return_against = frappe.db.get_value(sle.voucher_type, sle.voucher_no, 'return_against') + if return_against and return_against != sr.delivery_document_no: + frappe.throw(_("Serial no {0} has been already returned").format(sr.name)) + if sle.actual_qty < 0: if sr.warehouse!=sle.warehouse: frappe.throw(_("Serial No {0} does not belong to Warehouse {1}").format(serial_no,