Try ERPNext Buy Support Partners Foundation Foundation Members

Frappe Throw when Maintain Stock is not ticked

Im a beginner at javascript can someone help me on why this code is throwing “BOM does not contain any stock item” when our item’s “Maintain Stock” is not ticked/checked?

Thank you.

frappe.ui.form.on(‘Quotation’, {
refresh: function(frm) {
if (frm.doc.docstatus==0) {
frm.add_custom_button(__(“Bill of Materials”),
() => frm.events.get_items_from_bom(frm), __(“Get items from”));
}
},

get_items_from_bom: function(frm) {
var d = new frappe.ui.Dialog({
title: (“Get Items from BOM”),
fields: [
{“fieldname”:“bom”, “fieldtype”:“Link”, “label”:
(“BOM”),
options:“BOM”, reqd: 1, get_query: function() {
return {filters: { docstatus:1 }};
}},
{fieldname:“fetch”, “label”:(“Submit”), “fieldtype”:“Button”}
]
});
d.get_input(“fetch”).on(“click”, function() {
var values = d.get_values();
if(!values) return;
values[“company”] = frm.doc.company;
if(!frm.doc.company) frappe.throw(
(“Company field is required”));
frappe.call({
method: “erpnext.manufacturing.doctype.bom.bom.get_bom_items”,
args: values,
callback: function® {
if (!r.message) {
frappe.throw(__(“BOM does not contain any stock item”));
} else {
erpnext.utils.remove_empty_first_row(frm, “items”);
$.each(r.message, function(i, item) {
var d = frappe.model.add_child(cur_frm.doc, “Quotation Item”, “items”);
d.item_code = item.item_code;
d.item_name = item.item_name;
d.description = item.description;
d.uom = item.stock_uom;
d.stock_uom = item.stock_uom;
d.conversion_factor = 1;
d.qty = item.qty;
});
}
d.hide();
refresh_field(“items”);
}
});
});
d.show();
},

});