mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-22 19:55:29 +00:00
fix: Does not allow to create Sub-Asseblies of Sub Assemblies
(cherry picked from commit 318a945d66)
This commit is contained in:
committed by
Mergify
parent
a11c15a6cb
commit
d3c9092266
@@ -365,12 +365,6 @@ def get_children(doctype=None, parent=None, **kwargs):
|
|||||||
return frappe.get_all("BOM Creator Item", fields=fields, filters=query_filters, order_by="idx")
|
return frappe.get_all("BOM Creator Item", fields=fields, filters=query_filters, order_by="idx")
|
||||||
|
|
||||||
|
|
||||||
def get_parent_row_no(doc, name):
|
|
||||||
for row in doc.items:
|
|
||||||
if row.name == name:
|
|
||||||
return row.idx
|
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def add_item(**kwargs):
|
def add_item(**kwargs):
|
||||||
if isinstance(kwargs, str):
|
if isinstance(kwargs, str):
|
||||||
@@ -418,6 +412,8 @@ def add_sub_assembly(**kwargs):
|
|||||||
parent_row_no = ""
|
parent_row_no = ""
|
||||||
if not kwargs.convert_to_sub_assembly:
|
if not kwargs.convert_to_sub_assembly:
|
||||||
item_info = get_item_details(bom_item.item_code)
|
item_info = get_item_details(bom_item.item_code)
|
||||||
|
parent_row_no = get_parent_row_no(doc, kwargs.fg_reference_id)
|
||||||
|
|
||||||
item_row = doc.append(
|
item_row = doc.append(
|
||||||
"items",
|
"items",
|
||||||
{
|
{
|
||||||
@@ -426,6 +422,7 @@ def add_sub_assembly(**kwargs):
|
|||||||
"uom": item_info.stock_uom,
|
"uom": item_info.stock_uom,
|
||||||
"fg_item": kwargs.fg_item,
|
"fg_item": kwargs.fg_item,
|
||||||
"conversion_factor": 1,
|
"conversion_factor": 1,
|
||||||
|
"parent_row_no": parent_row_no,
|
||||||
"fg_reference_id": name,
|
"fg_reference_id": name,
|
||||||
"stock_qty": bom_item.qty,
|
"stock_qty": bom_item.qty,
|
||||||
"do_not_explode": 1,
|
"do_not_explode": 1,
|
||||||
@@ -437,9 +434,7 @@ def add_sub_assembly(**kwargs):
|
|||||||
parent_row_no = item_row.idx
|
parent_row_no = item_row.idx
|
||||||
name = ""
|
name = ""
|
||||||
else:
|
else:
|
||||||
parent_row_no = [row.idx for row in doc.items if row.name == kwargs.fg_reference_id]
|
parent_row_no = get_parent_row_no(doc, kwargs.fg_reference_id)
|
||||||
if parent_row_no:
|
|
||||||
parent_row_no = parent_row_no[0]
|
|
||||||
|
|
||||||
for row in bom_item.get("items"):
|
for row in bom_item.get("items"):
|
||||||
row = frappe._dict(row)
|
row = frappe._dict(row)
|
||||||
@@ -471,6 +466,14 @@ def get_item_details(item_code):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def get_parent_row_no(doc, name):
|
||||||
|
for row in doc.items:
|
||||||
|
if row.name == name:
|
||||||
|
return row.idx
|
||||||
|
|
||||||
|
frappe.msgprint(_("Parent Row No not found for {0}").format(name))
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def delete_node(**kwargs):
|
def delete_node(**kwargs):
|
||||||
if isinstance(kwargs, str):
|
if isinstance(kwargs, str):
|
||||||
|
|||||||
Reference in New Issue
Block a user