def get_doc_permissions(doc, verbose=False, user=None):
 if (not user):
  user = frappe.session.user
 if frappe.is_table(doc.doctype):
  return {u'read': 1, u'write': 1}
 meta = frappe.get_meta(doc.doctype)
 role_permissions = copy.deepcopy(get_role_permissions(meta, user=user, verbose=verbose))
 if (not cint(meta.is_submittable)):
  role_permissions[u'submit'] = 0
 if (not cint(meta.allow_import)):
  role_permissions[u'import'] = 0
 if role_permissions.get(u'apply_user_permissions'):
  for ptype in role_permissions:
   if (role_permissions[u'apply_user_permissions'].get(ptype) and (not user_has_permission(doc, verbose=verbose, user=user, user_permission_doctypes=(role_permissions.get(u'user_permission_doctypes', {}).get(ptype) or [])))):
    role_permissions[ptype] = 0
 if (doc.owner == frappe.session.user):
  role_permissions.update(role_permissions.if_owner)
 update_share_permissions(role_permissions, doc, user)
 return role_permissions

def get_doc_permissions ( doc , verbose = False , user = None ) : if ( not user ) : user = frappe . session . user if frappe . is_table ( doc . doctype ) : return { u'read' : 1 , u'write' : 1 } meta = frappe . get_meta ( doc . doctype ) role_permissions = copy . deepcopy ( get_role_permissions ( meta , user = user , verbose = verbose ) ) if ( not cint ( meta . is_submittable ) ) : role_permissions [ u'submit' ] = 0 if ( not cint ( meta . allow_import ) ) : role_permissions [ u'import' ] = 0 if role_permissions . get ( u'apply_user_permissions' ) : for ptype in role_permissions : if ( role_permissions [ u'apply_user_permissions' ] . get ( ptype ) and ( not user_has_permission ( doc , verbose = verbose , user = user , user_permission_doctypes = ( role_permissions . get ( u'user_permission_doctypes' , { } ) . get ( ptype ) or [ ] ) ) ) ) : role_permissions [ ptype ] = 0 if ( doc . owner == frappe . session . user ) : role_permissions . update ( role_permissions . if_owner ) update_share_permissions ( role_permissions , doc , user ) return role_permissions
returns a dict of evaluated permissions for given doc like {"read":1 .