fix: Duplicate Name Error Message on saving document

This commit is contained in:
marination 2020-07-03 14:10:44 +05:30
parent 7da16ee895
commit c2c6d9fa7f
2 changed files with 2 additions and 3 deletions

View file

@ -21,8 +21,7 @@ def savedocs(doc, action):
try:
doc.save()
except frappe.NameError as e:
doctype, name, original_exception = e if isinstance(e, tuple) else (doc.doctype or "", doc.name or "", None)
frappe.msgprint(frappe._("{0} {1} already exists").format(doctype, name))
# Duplicate Error message already shown on db_insert
raise
# update recent documents

View file

@ -334,7 +334,7 @@ class BaseDocument(object):
self.db_insert()
return
frappe.msgprint(_("Duplicate name {0} {1}").format(self.doctype, self.name))
frappe.msgprint(_("{0} {1} already exists").format(self.doctype, frappe.bold(self.name)), title=_("Duplicate Name"), indicator="red")
raise frappe.DuplicateEntryError(self.doctype, self.name, e)
elif frappe.db.is_unique_key_violation(e):