From f3caed378b54a12e1ca4e993825d8638bdc9bbfd Mon Sep 17 00:00:00 2001 From: Mohammad Umair Sayed Date: Thu, 11 Jun 2026 11:50:00 +0530 Subject: [PATCH] fix(bom): fetch routing operations when Routing is selected (#55813) fix(bom): fetch routing operations when routing is selected frm.doc.operations is always an array in Frappe, so !frm.doc.operations was always false (empty array [] is truthy in JS), causing get_routing() to never fire when a Routing is selected on a BOM with no existing operations. Changed the guard to !frm.doc.operations.length so the fetch triggers correctly when the operations table is empty. Also wired the same fetch into the with_operations handler so that enabling the checkbox after a Routing is already set will populate operations without requiring the user to re-select the Routing. Co-authored-by: Umair Sayed (cherry picked from commit 9249fa89aa6bd846b94292ca22e1b6bdf6d4e4c8) --- erpnext/manufacturing/doctype/bom/bom.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/erpnext/manufacturing/doctype/bom/bom.js b/erpnext/manufacturing/doctype/bom/bom.js index 2bf7e34bd4e..9fbe4f1174c 100644 --- a/erpnext/manufacturing/doctype/bom/bom.js +++ b/erpnext/manufacturing/doctype/bom/bom.js @@ -175,6 +175,9 @@ frappe.ui.form.on("BOM", { with_operations: function (frm) { frm.set_df_property("fg_based_operating_cost", "hidden", frm.doc.with_operations ? 1 : 0); frm.trigger("toggle_fields_for_semi_finished_goods"); + if (frm.doc.routing && frm.doc.with_operations && !frm.doc.operations.length) { + frm.trigger("routing"); + } }, fg_based_operating_cost: function (frm) { @@ -583,7 +586,7 @@ frappe.ui.form.on("BOM", { }, routing(frm) { - if (frm.doc.routing && frm.doc.with_operations && !frm.doc.operations) { + if (frm.doc.routing && frm.doc.with_operations && !frm.doc.operations.length) { frappe.call({ doc: frm.doc, method: "get_routing",