Skip to content

Commit

Permalink
fix: 'Use Multi-Level BOM' checkbox default value (#44618)
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitwaghchaure authored Dec 9, 2024
1 parent 616bb38 commit f5c038c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
16 changes: 7 additions & 9 deletions erpnext/manufacturing/doctype/bom/bom.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,15 +303,6 @@ frappe.ui.form.on("BOM", {
});
}

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({
fieldtype: "Float",
Expand Down Expand Up @@ -339,6 +330,13 @@ frappe.ui.form.on("BOM", {
cur_dialog.refresh();
},
});

fields.push({
fieldtype: "Check",
label: __("Use Multi-Level BOM"),
fieldname: "use_multi_level_bom",
default: frm.doc?.__onload.use_multi_level_bom,
});
}

var has_template_rm = frm.doc.items.filter((d) => d.has_variants === 1) || [];
Expand Down
17 changes: 17 additions & 0 deletions erpnext/manufacturing/doctype/bom/bom.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,23 @@ def get_index_for_bom(self, existing_boms):

return index

def onload(self):
super().onload()

self.set_onload_for_muulti_level_bom()

def set_onload_for_muulti_level_bom(self):
use_multi_level_bom = frappe.db.get_value(
"Property Setter",
{"field_name": "use_multi_level_bom", "doc_type": "Work Order", "property": "default"},
"value",
)

if use_multi_level_bom is None:
use_multi_level_bom = 1

self.set_onload("use_multi_level_bom", cint(use_multi_level_bom))

@staticmethod
def get_next_version_index(existing_boms: list[str]) -> int:
# split by "/" and "-"
Expand Down

0 comments on commit f5c038c

Please sign in to comment.