def set_user_image(fid, fname):
	"""
		Set uploaded image as user image
	"""
	from webnotes.utils.file_manager import add_file_list, remove_all
	remove_all('Profile', webnotes.session['user'])
	add_file_list('Profile', webnotes.session['user'], fname, fid)
Example #2
0
		
	try:
		tablefields = webnotes.model.meta.get_table_fields(doctype)
		webnotes.conn.sql("delete from `tab%s` where name=%s" % (doctype, "%s"), name)
		for t in tablefields:
			if t[0] not in ignore_doctypes:
				webnotes.conn.sql("delete from `tab%s` where parent = %s" % (t[0], '%s'), name)
	except Exception, e:
		if e.args[0]==1451:
			webnotes.msgprint("Cannot delete %s '%s' as it is referenced in another record. You must delete the referred record first" % (doctype, name))
		
		raise
		
	# delete attachments
	from webnotes.utils.file_manager import remove_all
	remove_all(doctype, name)
		
	return 'okay'

def check_permission_and_not_submitted(doctype, name, ignore_permissions=False):
	# permission
	if not ignore_permissions and webnotes.session.user!="Administrator" and not webnotes.has_permission(doctype, "cancel"):
		webnotes.msgprint(_("User not allowed to delete."), raise_exception=True)

	# check if submitted
	if webnotes.conn.get_value(doctype, name, "docstatus") == 1:
		webnotes.msgprint(_("Submitted Record cannot be deleted")+": "+name+"("+doctype+")",
			raise_exception=True)

def run_on_trash(doctype, name, doclist):
	# call on_trash if required