chore: warn bom naming conflict (#20244)

Co-authored-by: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com>
This commit is contained in:
Shivam Mishra 2020-01-27 15:20:30 +05:30 committed by Nabin Hait
parent ef41a0eda5
commit 149b4e5985

View File

@ -47,7 +47,18 @@ class BOM(WebsiteGenerator):
else:
idx = 1
self.name = 'BOM-' + self.item + ('-%.3i' % idx)
name = 'BOM-' + self.item + ('-%.3i' % idx)
if frappe.db.exists("BOM", name):
conflicting_bom = frappe.get_doc("BOM", name)
if conflicting_bom.item != self.item:
frappe.throw(_("""A BOM with name {0} already exists for item {1}.
<br> Did you rename the item? Please contact Administrator / Tech support
""").format(frappe.bold(name), frappe.bold(conflicting_bom.item)))
self.name = name
def validate(self):
self.route = frappe.scrub(self.name).replace('_', '-')