From de0c75bcbadbe8b97036b257e47ec21d2bed686d Mon Sep 17 00:00:00 2001 From: Mohd Haris Date: Thu, 9 Jul 2026 18:01:17 +0530 Subject: [PATCH] fix: update BOM operations when routing is changed The routing field handler only fetched operations from the routing when the operations table was empty. When a new BOM version is created (via "New Version"), operations are copied from the source BOM, so selecting a different routing left the old operations in place - both in the form and after saving. Drop the `!frm.doc.operations.length` guard from the routing handler so that (re)selecting a routing always refetches the operations from that routing via the existing get_routing method, which clears and repopulates the operations table. Co-Authored-By: Claude Opus 4.8 (cherry picked from commit 758a837de4b7e40653e33fdf8110b988e71187c3) --- erpnext/manufacturing/doctype/bom/bom.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/erpnext/manufacturing/doctype/bom/bom.js b/erpnext/manufacturing/doctype/bom/bom.js index e83f7e232ad..88a6c3bad66 100644 --- a/erpnext/manufacturing/doctype/bom/bom.js +++ b/erpnext/manufacturing/doctype/bom/bom.js @@ -441,7 +441,11 @@ frappe.ui.form.on("BOM", { }, routing(frm) { - if (frm.doc.routing && frm.doc.with_operations && !frm.doc.operations.length) { + // Refetch operations whenever the routing is (re)selected, so that + // changing the routing - e.g. on a new BOM version copied from another + // BOM - replaces the operations with those of the newly selected routing + // instead of keeping the old ones. + if (frm.doc.routing && frm.doc.with_operations) { frappe.call({ doc: frm.doc, method: "get_routing",