Skip to content

Commit

Permalink
fix: not able to save BOM Creator (#42540)
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitwaghchaure authored Jul 30, 2024
1 parent b7d70ac commit 61280e6
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions erpnext/manufacturing/doctype/bom_creator/bom_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,12 @@ def get_children(doctype=None, parent=None, **kwargs):
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()
def add_item(**kwargs):
if isinstance(kwargs, str):
Expand All @@ -375,6 +381,11 @@ def add_item(**kwargs):

doc = frappe.get_doc("BOM Creator", kwargs.parent)
item_info = get_item_details(kwargs.item_code)

parent_row_no = ""
if kwargs.fg_reference_id and doc.name != kwargs.fg_reference_id:
parent_row_no = get_parent_row_no(doc, kwargs.fg_reference_id)

kwargs.update(
{
"uom": item_info.stock_uom,
Expand All @@ -383,6 +394,9 @@ def add_item(**kwargs):
}
)

if parent_row_no:
kwargs.update({"parent_row_no": parent_row_no})

doc.append("items", kwargs)
doc.save()

Expand Down

0 comments on commit 61280e6

Please sign in to comment.