Skip to content

Commit f8dc16f

Browse files
committed
feat: add convert to phantom item support in bom creator
1 parent 0a366c4 commit f8dc16f

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

erpnext/manufacturing/doctype/bom_creator/bom_creator.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,9 @@ def add_sub_assembly(**kwargs):
465465
parent_row_no = item_row.idx
466466
name = ""
467467
else:
468+
if sbool(kwargs.phantom):
469+
parent_row = next(item for item in doc.items if item.name == kwargs.fg_reference_id)
470+
parent_row.db_set("is_phantom_item", 1)
468471
parent_row_no = get_parent_row_no(doc, kwargs.fg_reference_id)
469472

470473
for row in bom_item.get("items"):

erpnext/public/js/bom_configurator/bom_configurator.bundle.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,17 @@ class BOMConfigurator {
181181
},
182182
btnClass: "hidden-xs",
183183
},
184+
{
185+
label: __(frappe.utils.icon("move", "sm") + " Phantom Item"),
186+
click: function (node) {
187+
let view = frappe.views.trees["BOM Configurator"];
188+
view.events.convert_to_sub_assembly(node, view, true);
189+
},
190+
condition: function (node) {
191+
return !node.expandable;
192+
},
193+
btnClass: "hidden-xs",
194+
},
184195
{
185196
label: __(frappe.utils.icon("delete", "sm") + " Item"),
186197
click: function (node) {
@@ -399,10 +410,10 @@ class BOMConfigurator {
399410
return fields;
400411
}
401412

402-
convert_to_sub_assembly(node, view) {
413+
convert_to_sub_assembly(node, view, phantom = false) {
403414
let dialog = new frappe.ui.Dialog({
404-
fields: view.events.get_sub_assembly_modal_fields(view, node.is_root, true),
405-
title: __("Add Sub Assembly"),
415+
fields: view.events.get_sub_assembly_modal_fields(view, node.is_root, true, phantom),
416+
title: phantom ? __("Add Phantom Item") : __("Add Sub Assembly"),
406417
});
407418

408419
dialog.set_values({
@@ -415,7 +426,9 @@ class BOMConfigurator {
415426
let bom_item = dialog.get_values();
416427

417428
if (!bom_item.item_code) {
418-
frappe.throw(__("Sub Assembly Item is mandatory"));
429+
frappe.throw(
430+
phantom ? __("Phantom Item is mandatory") : __("Sub Assembly Item is mandatory")
431+
);
419432
}
420433

421434
bom_item.items.forEach((d) => {
@@ -440,6 +453,7 @@ class BOMConfigurator {
440453
workstation_type: node.data.workstation_type,
441454
operation_time: node.data.operation_time,
442455
workstation: node.data.workstation,
456+
phantom: phantom,
443457
},
444458
callback: (r) => {
445459
node.expandable = true;

0 commit comments

Comments
 (0)