From 24f1f3dea88d76fa70ef83a4e20b851fbfc32d7a Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Sat, 8 Aug 2026 15:27:39 +0530 Subject: [PATCH] fix: add raw material to its operation even when another operation uses the item MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit get_item_details returns the whole Item document, so the dialog row's name became the item code. get_item_data then matched that item code against every Components row regardless of operation, so adding an item already used by another operation silently updated that row's qty instead of appending one for the target operation — which stayed empty and failed 'please add raw materials or set a BOM' on submit. Match the existing row by item code within the same operation: same operation updates the qty, any other match appends a new row. --- erpnext/manufacturing/doctype/bom/bom.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py index 3da64ef08e8..f5cd1dc0c21 100644 --- a/erpnext/manufacturing/doctype/bom/bom.py +++ b/erpnext/manufacturing/doctype/bom/bom.py @@ -813,15 +813,10 @@ class BOM(WebsiteGenerator): row.update(get_item_details(row.get("item_code"))) row.operation_row_id = operation_row_id - item_row = self.get_item_data(row.name) if row.name else None + item_row = self.get_item_data(row.item_code, operation_row_id) if item_row: - item_row.update( - { - "item_code": row.get("item_code"), - "qty": row.get("qty"), - } - ) + item_row.qty = row.get("qty") else: row.idx = None row.name = None @@ -840,9 +835,9 @@ class BOM(WebsiteGenerator): return False - def get_item_data(self, name): + def get_item_data(self, item_code, operation_row_id): for row in self.items: - if row.item_code == name: + if row.item_code == item_code and cint(row.operation_row_id) == cint(operation_row_id): return row @frappe.whitelist()