def has_permission(doc, ptype="read", user=None):
	user = user or frappe.session.user
	todo_roles = frappe.permissions.get_doctype_roles('ToDo', ptype)
	if 'All' in todo_roles:
		todo_roles.remove('All')

	if any(check in todo_roles for check in frappe.get_roles(user)):
		return True
	else:
		return doc.allocated_to==user or doc.assigned_by==user