mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-01 11:22:11 +02:00
fix: not able to save BOM Creator (#42540)
This commit is contained in:
@@ -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")
|
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):
|
||||||
@@ -375,6 +381,11 @@ def add_item(**kwargs):
|
|||||||
|
|
||||||
doc = frappe.get_doc("BOM Creator", kwargs.parent)
|
doc = frappe.get_doc("BOM Creator", kwargs.parent)
|
||||||
item_info = get_item_details(kwargs.item_code)
|
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(
|
kwargs.update(
|
||||||
{
|
{
|
||||||
"uom": item_info.stock_uom,
|
"uom": item_info.stock_uom,
|
||||||
@@ -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.append("items", kwargs)
|
||||||
doc.save()
|
doc.save()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user