fix: variant items not fetched while making BOM for Variant Item

(cherry picked from commit a0256bd798)
This commit is contained in:
Rohit Waghchaure
2025-12-03 19:24:21 +05:30
committed by Mergify
parent dd888fc30a
commit 176ce0d4d6
2 changed files with 10 additions and 1 deletions

View File

@@ -389,10 +389,12 @@ frappe.ui.form.on("BOM", {
); );
has_template_rm.forEach((d) => { has_template_rm.forEach((d) => {
let bom_qty = dialog.fields_dict.qty?.value || 1;
dialog.fields_dict.items.df.data.push({ dialog.fields_dict.items.df.data.push({
item_code: d.item_code, item_code: d.item_code,
variant_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, source_warehouse: d.source_warehouse,
operation: d.operation, operation: d.operation,
}); });

View File

@@ -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) 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 = frappe.new_doc("Work Order")
wo_doc.production_item = item wo_doc.production_item = item
wo_doc.update(item_details) wo_doc.update(item_details)