From e6f431a8d6f883b02ca1a6246df7e0ac564170d5 Mon Sep 17 00:00:00 2001 From: Pandiyan P Date: Fri, 11 Sep 2026 17:50:30 +0530 Subject: [PATCH] fix: prevent disabled items from being used in BOM (#58997) Co-authored-by: Ajish18 --- erpnext/manufacturing/doctype/bom/bom.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py index b9502c74cc6..9e5ac40e502 100644 --- a/erpnext/manufacturing/doctype/bom/bom.py +++ b/erpnext/manufacturing/doctype/bom/bom.py @@ -902,6 +902,19 @@ class BOM(WebsiteGenerator): ) ) + bom_items = {self.item, *items} + bom_items.update(d.item_code for d in self.get("secondary_items")) + bom_items.update(d.finished_good for d in self.get("operations") if d.finished_good) + + if disabled_items := frappe.db.get_all( + "Item", filters={"item_code": ("in", list(bom_items)), "disabled": 1}, pluck="name" + ): + frappe.throw( + _("Disabled Item {0} cannot be used in BOMs.").format( + ", ".join(get_link_to_form("Item", item) for item in disabled_items) + ) + ) + def check_recursion(self): """Check whether recursion occurs in any bom""" bom_list = self.traverse_tree()