From 3497a6a6bf87d5ee2c80ef20a7b7750a06b658fe Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Sat, 8 Aug 2026 14:39:42 +0530 Subject: [PATCH] fix: require FG / Semi FG Item on operations when tracking semi finished goods A BOM with track_semi_finished_goods enabled could be saved with no finished_good on any operation: validate_semi_finished_goods only checked that one row had 'Is Final Finished Good' set, and a list containing None passed the emptiness check. Such a BOM breaks every downstream step. The work order copies the empty finished_good into its operations, job cards inherit it, and Make Stock Entry finally fails with 'Item None not found' because the manufacture entry has no production item. Derive the finished good where it is unambiguous: an operation that references a BOM produces that BOM's item, and the final operation produces the BOM's own item. Otherwise require it on the row, since each operation's job card books its output through it. --- erpnext/manufacturing/doctype/bom/bom.py | 13 +++++++++++++ .../doctype/bom_operation/bom_operation.json | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py index 2717da14826..3da64ef08e8 100644 --- a/erpnext/manufacturing/doctype/bom/bom.py +++ b/erpnext/manufacturing/doctype/bom/bom.py @@ -346,6 +346,19 @@ class BOM(WebsiteGenerator): fg_items = [] for row in self.operations: + if row.bom_no and not row.finished_good: + row.finished_good = frappe.get_cached_value("BOM", row.bom_no, "item") + + if row.is_final_finished_good and not row.finished_good: + row.finished_good = self.item + + if not row.finished_good: + frappe.throw( + _( + "Row #{0}: FG / Semi FG Item is required for the operation {1} as 'Track Semi Finished Goods' is enabled." + ).format(row.idx, bold(row.operation)), + ) + if not row.is_final_finished_good: continue diff --git a/erpnext/manufacturing/doctype/bom_operation/bom_operation.json b/erpnext/manufacturing/doctype/bom_operation/bom_operation.json index 86fcd7082fd..e6ac3ee474e 100644 --- a/erpnext/manufacturing/doctype/bom_operation/bom_operation.json +++ b/erpnext/manufacturing/doctype/bom_operation/bom_operation.json @@ -213,6 +213,7 @@ "fieldtype": "Link", "in_list_view": 1, "label": "FG / Semi FG Item", + "mandatory_depends_on": "eval:parent.track_semi_finished_goods === 1", "options": "Item" }, { @@ -307,7 +308,7 @@ "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2026-05-25 17:15:42.044630", + "modified": "2026-08-08 12:00:00.000000", "modified_by": "Administrator", "module": "Manufacturing", "name": "BOM Operation",