fix: BOM has not attr required items (backport #44598) (#44600)

fix: BOM has not attr required items (#44598)

(cherry picked from commit 42d238da14)

Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
(cherry picked from commit 608eaaa482)
This commit is contained in:
mergify[bot]
2024-12-08 16:06:41 +05:30
committed by Mergify
parent 6f80af0355
commit 971e474640
2 changed files with 25 additions and 7 deletions

View File

@@ -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({
@@ -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",
@@ -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",

View File

@@ -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: