From 176ce0d4d67459ab1305c20682fa04f2b2d3218c Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Wed, 3 Dec 2025 19:24:21 +0530 Subject: [PATCH] fix: variant items not fetched while making BOM for Variant Item (cherry picked from commit a0256bd798d039ffc297daac560627918025219b) --- erpnext/manufacturing/doctype/bom/bom.js | 4 +++- erpnext/manufacturing/doctype/work_order/work_order.py | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/erpnext/manufacturing/doctype/bom/bom.js b/erpnext/manufacturing/doctype/bom/bom.js index b6c1f636b18..313a9de4e4b 100644 --- a/erpnext/manufacturing/doctype/bom/bom.js +++ b/erpnext/manufacturing/doctype/bom/bom.js @@ -389,10 +389,12 @@ frappe.ui.form.on("BOM", { ); has_template_rm.forEach((d) => { + let bom_qty = dialog.fields_dict.qty?.value || 1; + dialog.fields_dict.items.df.data.push({ item_code: d.item_code, variant_item_code: "", - qty: (d.qty / frm.doc.quantity) * (dialog.fields_dict.qty.value || 1), + qty: flt(d.qty / frm.doc.quantity) * flt(bom_qty), source_warehouse: d.source_warehouse, operation: d.operation, }); diff --git a/erpnext/manufacturing/doctype/work_order/work_order.py b/erpnext/manufacturing/doctype/work_order/work_order.py index 9d862e84da7..5e4dcf22431 100644 --- a/erpnext/manufacturing/doctype/work_order/work_order.py +++ b/erpnext/manufacturing/doctype/work_order/work_order.py @@ -1373,6 +1373,13 @@ def make_work_order(bom_no, item, qty=0, project=None, variant_items=None, use_m item_details = get_item_details(item, project) + if frappe.db.get_value("Item", item, "variant_of"): + if variant_bom := frappe.db.get_value( + "BOM", + {"item": item, "is_default": 1, "docstatus": 1}, + ): + bom_no = variant_bom + wo_doc = frappe.new_doc("Work Order") wo_doc.production_item = item wo_doc.update(item_details)