def has_controller_permissions(doc, ptype, user=None):
 if (not user):
  user = frappe.session.user
 methods = frappe.get_hooks(u'has_permission').get(doc.doctype, [])
 if (not methods):
  return None
 for method in methods:
  controller_permission = frappe.call(frappe.get_attr(method), doc=doc, ptype=ptype, user=user)
  if (controller_permission is not None):
   return controller_permission
 return None

def has_controller_permissions ( doc , ptype , user = None ) : if ( not user ) : user = frappe . session . user methods = frappe . get_hooks ( u'has_permission' ) . get ( doc . doctype , [ ] ) if ( not methods ) : return None for method in methods : controller_permission = frappe . call ( frappe . get_attr ( method ) , doc = doc , ptype = ptype , user = user ) if ( controller_permission is not None ) : return controller_permission return None
returns controller permissions if defined .