From b261242792e5cf88384fbe03890e4afb4b8e1736 Mon Sep 17 00:00:00 2001 From: s-aga-r Date: Fri, 16 Jun 2023 16:28:49 +0530 Subject: [PATCH] fix(ux): set route options for new `Batch` --- erpnext/public/js/controllers/transaction.js | 9 +++++++++ erpnext/stock/doctype/stock_entry/stock_entry.js | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 83630df3a0b..26dd13c3e3f 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -123,6 +123,15 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe this.frm.set_query("batch_no", "items", function(doc, cdt, cdn) { return me.set_query_for_batch(doc, cdt, cdn); }); + + let batch_field = this.frm.get_docfield('items', 'batch_no'); + if (batch_field) { + batch_field.get_route_options_for_new_doc = (row) => { + return { + 'item': row.doc.item_code + } + }; + } } if( diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js index bc5ac2addb0..dd08ef4d1e3 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.js +++ b/erpnext/stock/doctype/stock_entry/stock_entry.js @@ -101,6 +101,14 @@ frappe.ui.form.on('Stock Entry', { } }); + let batch_field = frm.get_docfield('items', 'batch_no'); + if (batch_field) { + batch_field.get_route_options_for_new_doc = (row) => { + return { + 'item': row.doc.item_code + } + }; + } frm.add_fetch("bom_no", "inspection_required", "inspection_required"); erpnext.accounts.dimensions.setup_dimension_filters(frm, frm.doctype);