Skip to content

Commit

Permalink
fix: BOM has not attr required items (backport #44598) (#44600)
Browse files Browse the repository at this point in the history
fix: BOM has not attr required items (#44598)

(cherry picked from commit 42d238d)

Co-authored-by: rohitwaghchaure <[email protected]>
  • Loading branch information
mergify[bot] and rohitwaghchaure authored Dec 8, 2024
1 parent a5cc307 commit 608eaaa
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
28 changes: 22 additions & 6 deletions erpnext/manufacturing/doctype/bom/bom.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,14 @@ frappe.ui.form.on("BOM", {
});
}

fields.push({
fieldtype: "Check",
label: __("Use Multi-Level BOM"),
fieldname: "use_multi_level_bom",
default: 1,
});
if (!skip_qty_field) {
fields.push({
fieldtype: "Check",
label: __("Use Multi-Level BOM"),
fieldname: "use_multi_level_bom",
default: 1,
});
}

if (!skip_qty_field) {
fields.push({
Expand Down Expand Up @@ -306,6 +308,13 @@ frappe.ui.form.on("BOM", {
fieldtype: "Link",
in_list_view: 1,
reqd: 1,
get_query() {
return {
filters: {
has_variants: 1,
},
};
},
},
{
fieldname: "variant_item_code",
Expand All @@ -326,6 +335,13 @@ frappe.ui.form.on("BOM", {
},
};
},
change() {
let doc = this.doc;
if (!doc.qty) {
doc.qty = 1.0;
this.grid.set_value("qty", 1.0, doc);
}
},
},
{
fieldname: "qty",
Expand Down
4 changes: 3 additions & 1 deletion erpnext/manufacturing/doctype/work_order/work_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -1360,7 +1360,9 @@ def add_variant_item(variant_items, wo_doc, bom_no, table_name="items"):
args["amount"] = flt(args.get("required_qty")) * flt(args.get("rate"))
args["uom"] = item_data.stock_uom

existing_row = get_template_rm_item(wo_doc, item.get("item_code"))
existing_row = (
get_template_rm_item(wo_doc, item.get("item_code")) if table_name == "required_items" else None
)
if existing_row:
existing_row.update(args)
else:
Expand Down

0 comments on commit 608eaaa

Please sign in to comment.