diff --git a/erpnext/stock/doctype/item/item.js b/erpnext/stock/doctype/item/item.js index af59eacd0df..b25fc06e2dd 100644 --- a/erpnext/stock/doctype/item/item.js +++ b/erpnext/stock/doctype/item/item.js @@ -87,16 +87,40 @@ frappe.ui.form.on("Item", { toggle_has_serial_batch_fields(frm) { let hide_fields = cint(frappe.user_defaults?.enable_serial_and_batch_no_for_item) === 0 ? 1 : 0; - frm.toggle_display(["serial_no_series", "batch_number_series", "create_new_batch"], !hide_fields); + frm.toggle_display( + [ + "serial_no_series", + "batch_number_series", + "create_new_batch", + "has_expiry_date", + "retain_sample", + ], + !hide_fields + ); frm.toggle_enable(["has_serial_no", "has_batch_no"], !hide_fields); if (hide_fields) { - let description = __( - "To enable the Serial No and Batch No feature, please check the 'Enable Serial / Batch No for Item' checkbox in Stock Settings." - ); + let header = frm.fields_dict["serial_nos_and_batches"].wrapper; + let wrapper = header.find(".section-head.collapsible"); - frm.set_df_property("has_serial_no", "description", description); - frm.set_df_property("has_batch_no", "description", description); + render_serial_batch_banner(wrapper); + + if (!wrapper.data("banner-handler-added")) { + wrapper.data("banner-handler-added", true); + + wrapper.on("click", function () { + setTimeout(() => { + let isCollapsed = $(this).hasClass("collapsed"); + + wrapper.find(".custom-serial-batch-banner").toggleClass("hidden", isCollapsed); + }, 10); + }); + } + + // Button action + wrapper.find(".go-to-settings").on("click", function () { + frappe.set_route("Form", "Stock Settings"); + }); } }, @@ -372,6 +396,63 @@ var set_customer_group = function (frm, cdt, cdn) { return true; }; +function render_serial_batch_banner(wrapper) { + let hiddenClass = ""; + if (wrapper.hasClass("collapsed")) { + hiddenClass = "hidden"; + } + + wrapper.find(".custom-serial-batch-banner").remove(); + + let banner_html = ` +
+ + `; + + // Insert banner at top of section + wrapper.append(banner_html); +} + $.extend(erpnext.item, { setup_queries: function (frm) { frm.fields_dict["item_defaults"].grid.get_field("expense_account").get_query = function ( diff --git a/erpnext/stock/doctype/item/item.json b/erpnext/stock/doctype/item/item.json index e4996462278..75dcd140474 100644 --- a/erpnext/stock/doctype/item/item.json +++ b/erpnext/stock/doctype/item/item.json @@ -433,7 +433,7 @@ "depends_on": "eval:doc.is_stock_item", "fieldname": "serial_nos_and_batches", "fieldtype": "Section Break", - "label": "Serial Nos and Batches" + "label": "Serial Nos / Batches" }, { "default": "0", @@ -995,7 +995,7 @@ "image_field": "image", "links": [], "make_attachments_public": 1, - "modified": "2026-03-24 15:45:40.207531", + "modified": "2026-04-14 13:37:00.183583", "modified_by": "Administrator", "module": "Stock", "name": "Item", diff --git a/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py b/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py index 5daab368156..67a85a03705 100644 --- a/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py +++ b/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py @@ -148,7 +148,7 @@ class SerialandBatchBundle(Document): if not frappe.db.get_single_value("Stock Settings", "enable_serial_and_batch_no_for_item"): frappe.throw( _( - "Please check the 'Enable Serial and Batch No for Item' checkbox in the {0} to make Serial and Batch Bundle for the item." + "Please check the 'Activate Serial and Batch No for Item' checkbox in the {0} to make Serial and Batch Bundle for the item." ).format(get_link_to_form("Stock Settings", "Stock Settings")), title=_("Serial and Batch No for Item Disabled"), ) diff --git a/erpnext/stock/doctype/stock_settings/stock_settings.js b/erpnext/stock/doctype/stock_settings/stock_settings.js index 76651bf69fe..00f91ed6b41 100644 --- a/erpnext/stock/doctype/stock_settings/stock_settings.js +++ b/erpnext/stock/doctype/stock_settings/stock_settings.js @@ -15,6 +15,12 @@ frappe.ui.form.on("Stock Settings", { frm.set_query("sample_retention_warehouse", filters); }, + enable_serial_and_batch_no_for_item(frm) { + if (frm.doc.enable_serial_and_batch_no_for_item) { + frappe.msgprint(__("After save, please refresh the page to apply the changes.")); + } + }, + use_serial_batch_fields(frm) { if (frm.doc.use_serial_batch_fields && !frm.doc.disable_serial_no_and_batch_selector) { frm.set_value("disable_serial_no_and_batch_selector", 1); diff --git a/erpnext/stock/doctype/stock_settings/stock_settings.json b/erpnext/stock/doctype/stock_settings/stock_settings.json index 8e42e4d3177..0b298bd2839 100644 --- a/erpnext/stock/doctype/stock_settings/stock_settings.json +++ b/erpnext/stock/doctype/stock_settings/stock_settings.json @@ -528,18 +528,18 @@ "label": "Allow Negative Stock for Batch" }, { + "default": "0", "fieldname": "enable_serial_and_batch_no_for_item", "fieldtype": "Check", - "label": "Enable Serial / Batch No for Item" + "label": "Activate Serial / Batch No for Item" } ], - "hide_toolbar": 0, "icon": "icon-cog", "idx": 1, "index_web_pages_for_search": 1, "issingle": 1, "links": [], - "modified": "2026-03-27 22:39:16.812184", + "modified": "2026-04-14 13:51:49.545114", "modified_by": "Administrator", "module": "Stock", "name": "Stock Settings",