Browse Source

Fix in error message on deletion: show parent name if it exists

version-14
Anand Doshi 13 years ago
parent
commit
ac79e47ce6
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      py/webnotes/model/__init__.py

+ 2
- 2
py/webnotes/model/__init__.py View File

@@ -50,12 +50,12 @@ def check_if_doc_is_linked(dt, dn):
else:
item = None
try:
item = sql("select name, parent from `tab%s` where `%s`='%s' and docstatus!=2 limit 1" % (link_dt, link_field, dn))
item = sql("select name, parent, parenttype from `tab%s` where `%s`='%s' and docstatus!=2 limit 1" % (link_dt, link_field, dn))
except Exception, e:
if e.args[0]==1146: pass
else: raise e
if item:
webnotes.msgprint("Cannot delete %s <b>%s</b> because it is linked in %s <b>%s</b>" % (dt, dn, link_dt, item[0][1] or item[0][0]), raise_exception=1)
webnotes.msgprint("Cannot delete %s <b>%s</b> because it is linked in %s <b>%s</b>" % (dt, dn, item[0][2] or link_dt, item[0][1] or item[0][0]), raise_exception=1)

@webnotes.whitelist()
def delete_doc(doctype=None, name=None, doclist = None, force=0):


Loading…
Cancel
Save