diff --git a/erpnext/public/js/utils/serial_no_batch_selector.js b/erpnext/public/js/utils/serial_no_batch_selector.js index 4ec12ce8e7f..23895ee4c02 100644 --- a/erpnext/public/js/utils/serial_no_batch_selector.js +++ b/erpnext/public/js/utils/serial_no_batch_selector.js @@ -90,7 +90,8 @@ erpnext.SerialNoBatchSelector = Class.extend({ args: { qty: qty, item_code: me.item_code, - warehouse: me.warehouse_details.name + warehouse: me.warehouse_details.name, + batch_no: me.item.batch_no || null } }); @@ -392,7 +393,7 @@ erpnext.SerialNoBatchSelector = Class.extend({ delivery_document_no: "" } - if (this.has_batch) { + if (this.item.batch_no) { serial_no_filters["batch_no"] = this.item.batch_no; } diff --git a/erpnext/stock/doctype/serial_no/serial_no.py b/erpnext/stock/doctype/serial_no/serial_no.py index 19eb398130c..c8e9b011be9 100644 --- a/erpnext/stock/doctype/serial_no/serial_no.py +++ b/erpnext/stock/doctype/serial_no/serial_no.py @@ -397,7 +397,6 @@ def make_serial_no(serial_no, args): sr.via_stock_ledger = args.get('via_stock_ledger') or True sr.asset = args.get('asset') sr.location = args.get('location') - if args.get('purchase_document_type'): sr.purchase_document_type = args.get('purchase_document_type') @@ -474,10 +473,11 @@ def get_delivery_note_serial_no(item_code, qty, delivery_note): return serial_nos @frappe.whitelist() -def auto_fetch_serial_number(qty, item_code, warehouse): +def auto_fetch_serial_number(qty, item_code, warehouse, batch_no=None): serial_numbers = frappe.get_list("Serial No", filters={ "item_code": item_code, "warehouse": warehouse, + "batch_no": batch_no, "delivery_document_no": "", "sales_invoice": "" }, limit=qty, order_by="creation")