diff --git a/erpnext/manufacturing/doctype/bom_creator/bom_creator.py b/erpnext/manufacturing/doctype/bom_creator/bom_creator.py index 2a2565b8cf188ae7e926afe3cfea2ec3cb807351..c76f6b944a872930736c8d48299ffb666f5a93a9 100644 --- a/erpnext/manufacturing/doctype/bom_creator/bom_creator.py +++ b/erpnext/manufacturing/doctype/bom_creator/bom_creator.py @@ -47,6 +47,18 @@ class BOMCreator(Document): if row.is_expandable and row.item_code == self.item_code: frappe.throw(_("Item {0} cannot be added as a sub-assembly of itself").format(row.item_code)) + if not row.parent_row_no and row.fg_item and row.fg_item != self.item_code: + frappe.throw( + _("At row {0}: set Parent Row No for item {1}").format(row.idx, row.item_code), + title=_("Set Parent Row No in Items Table"), + ) + + elif row.parent_row_no and row.fg_item == self.item_code: + frappe.throw( + _("At row {0}: Parent Row No cannot be set for item {1}").format(row.idx, row.item_code), + title=_("Remove Parent Row No in Items Table"), + ) + def set_status(self, save=False): self.status = { 0: "Draft", @@ -383,6 +395,10 @@ def add_sub_assembly(**kwargs): parent_row_no = item_row.idx name = "" + else: + parent_row_no = [row.idx for row in doc.items if row.name == kwargs.fg_reference_id] + if parent_row_no: + parent_row_no = parent_row_no[0] for row in bom_item.get("items"): row = frappe._dict(row)