Skip to content

Commit

Permalink
fix: 'Use Multi-Level BOM' checkbox default value (backport #44618) (#…
Browse files Browse the repository at this point in the history
…44620)

fix: 'Use Multi-Level BOM' checkbox default value (#44618)

(cherry picked from commit f5c038c)

Co-authored-by: rohitwaghchaure <[email protected]>
  • Loading branch information
mergify[bot] and rohitwaghchaure authored Dec 10, 2024
1 parent eae5996 commit 5cd3994
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 @@ -255,15 +255,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 @@ -291,6 +282,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 @@ -214,6 +214,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 5cd3994

Please sign in to comment.