From fff261680c14cdd7bf8791e07597afa216344a1a Mon Sep 17 00:00:00 2001
From: Krishna Pramod Shirsath <91021227+krishna-254@users.noreply.github.com>
Date: Wed, 2 Sep 2026 13:33:15 +0530
Subject: [PATCH] fix: filter cancelled BOMs in BOM Stock Analysis (#58647)
(cherry picked from commit a2071a6fddcc3a18cd01e4ed6d1e7fc42352258c)
# Conflicts:
# erpnext/manufacturing/report/bom_stock_analysis/bom_stock_analysis.js
---
.../bom_stock_analysis/bom_stock_analysis.js | 60 +++++++++++++++++++
1 file changed, 60 insertions(+)
create mode 100644 erpnext/manufacturing/report/bom_stock_analysis/bom_stock_analysis.js
diff --git a/erpnext/manufacturing/report/bom_stock_analysis/bom_stock_analysis.js b/erpnext/manufacturing/report/bom_stock_analysis/bom_stock_analysis.js
new file mode 100644
index 00000000000..3d11a7d7263
--- /dev/null
+++ b/erpnext/manufacturing/report/bom_stock_analysis/bom_stock_analysis.js
@@ -0,0 +1,60 @@
+// Copyright (c) 2026, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+
+frappe.query_reports["BOM Stock Analysis"] = {
+ filters: [
+ {
+ fieldname: "bom",
+ label: __("BOM"),
+ fieldtype: "Link",
+ options: "BOM",
+ reqd: 1,
+ get_query: () => ({ filters: { docstatus: 1 } }),
+ },
+ {
+ fieldname: "warehouse",
+ label: __("Warehouse"),
+ fieldtype: "Link",
+ options: "Warehouse",
+ },
+ {
+ fieldname: "qty_to_make",
+ label: __("FG Items to Make"),
+ fieldtype: "Float",
+ },
+ {
+ fieldname: "show_exploded_view",
+ label: __("Show availability of exploded items"),
+ fieldtype: "Check",
+ default: false,
+ },
+ ],
+ formatter(value, row, column, data, default_formatter) {
+ if (data && data.bold && column.fieldname === "item") {
+ return value ? `${value}` : "";
+ }
+
+ value = default_formatter(value, row, column, data);
+
+ if (column.fieldname === "difference_qty" && value !== "" && value !== undefined) {
+ const numeric = parseFloat(value.replace(/,/g, "")) || 0;
+ if (numeric < 0) {
+ value = `${value}`;
+ } else if (numeric > 0) {
+ value = `${value}`;
+ }
+ }
+
+ if (data && data.bold) {
+ if (column.fieldname === "description") {
+ const qty_to_make = Number(frappe.query_report.get_filter_value("qty_to_make")) || 0;
+ const producible = Number(String(data.description ?? "").replace(/,/g, "")) || 0;
+ const colour = qty_to_make && producible < qty_to_make ? "red" : "green";
+ return `${value}`;
+ }
+ return `${value}`;
+ }
+
+ return value;
+ },
+};