From 3e11338ed55898ec4f7728a03fb1d6f1ff5e258b Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Thu, 29 Aug 2019 19:46:49 +0530 Subject: [PATCH] fix: Validate count of serial numbers --- erpnext/stock/doctype/pick_list/pick_list.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/erpnext/stock/doctype/pick_list/pick_list.py b/erpnext/stock/doctype/pick_list/pick_list.py index 21b9cc10543..efe6da8e157 100644 --- a/erpnext/stock/doctype/pick_list/pick_list.py +++ b/erpnext/stock/doctype/pick_list/pick_list.py @@ -16,6 +16,15 @@ from erpnext.selling.doctype.sales_order.sales_order import make_delivery_note a # TODO: Prioritize SO or WO group warehouse class PickList(Document): + def before_submit(self): + for item in self.locations: + if not frappe.get_cached_value('Item', item.item_code, 'has_serial_no'): + continue + if len(item.serial_no.split('\n')) == item.picked_qty: + continue + frappe.throw(_('For item {0} at row {1}, count of serial numbers does not match with the picked quantity') + .format(frappe.bold(item.item_code), frappe.bold(item.idx))) + def set_item_locations(self): items = self.aggregate_item_qty() self.item_location_map = frappe._dict()