diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py index 46bf75780d4f..5a6edb703fa3 100644 --- a/erpnext/manufacturing/doctype/bom/bom.py +++ b/erpnext/manufacturing/doctype/bom/bom.py @@ -7,7 +7,7 @@ from operator import itemgetter import frappe -from frappe import _ +from frappe import _, bold from frappe.core.doctype.version.version import get_diff from frappe.model.mapper import get_mapped_doc from frappe.utils import cint, cstr, flt, today @@ -655,9 +655,16 @@ def validate_materials(self): def check_recursion(self, bom_list=None): """Check whether recursion occurs in any bom""" - def _throw_error(bom_name): + def _throw_error(bom_name, production_item=None): + msg = _("BOM recursion: {1} cannot be parent or child of {0}").format(self.name, bom_name) + if production_item and bom_name != self.name: + msg += "

" + msg += _( + "Note: If you want to use the finished good {0} as a raw material, then enable the 'Do Not Explode' checkbox in the Items table against the same raw material." + ).format(bold(production_item)) + frappe.throw( - _("BOM recursion: {1} cannot be parent or child of {0}").format(self.name, bom_name), + msg, exc=BOMRecursionError, ) @@ -674,7 +681,7 @@ def _throw_error(bom_name): if self.item == item.item_code and item.bom_no: # Same item but with different BOM should not be allowed. # Same item can appear recursively once as long as it doesn't have BOM. - _throw_error(item.bom_no) + _throw_error(item.bom_no, self.item) if self.name in {d.bom_no for d in self.items}: _throw_error(self.name)