@frappe.whitelist()
def set_permission(doctype, name, user, permission_to, value=1, everyone=0):
 check_share_permission(doctype, name)
 share_name = get_share_name(doctype, name, user, everyone)
 value = int(value)
 if (not share_name):
  if value:
   share = add(doctype, name, user, everyone=everyone, **{permission_to: 1})
  else:
   share = {}
   pass
 else:
  share = frappe.get_doc(u'DocShare', share_name)
  share.flags.ignore_permissions = True
  share.set(permission_to, value)
  if (not value):
   if (permission_to == u'read'):
    share.read = share.write = share.share = 0
  share.save()
  if (not (share.read or share.write or share.share)):
   share.delete()
   share = {}
 return share

@ frappe . whitelist ( ) def set_permission ( doctype , name , user , permission_to , value = 1 , everyone = 0 ) : check_share_permission ( doctype , name ) share_name = get_share_name ( doctype , name , user , everyone ) value = int ( value ) if ( not share_name ) : if value : share = add ( doctype , name , user , everyone = everyone , ** { permission_to : 1 } ) else : share = { } pass else : share = frappe . get_doc ( u'DocShare' , share_name ) share . flags . ignore_permissions = True share . set ( permission_to , value ) if ( not value ) : if ( permission_to == u'read' ) : share . read = share . write = share . share = 0 share . save ( ) if ( not ( share . read or share . write or share . share ) ) : share . delete ( ) share = { } return share
generates permission bits from dictionary .