def pr_remove_affiliation(master, affiliate, role=None):
 master_pe = pr_get_pe_id(master)
 affiliate_pe = pr_get_pe_id(affiliate)
 if affiliate_pe:
  s3db = current.s3db
  atable = s3db.pr_affiliation
  rtable = s3db.pr_role
  query = ((atable.pe_id == affiliate_pe) & (atable.role_id == rtable.id))
  if master_pe:
   query &= (rtable.pe_id == master_pe)
  if role:
   query &= (rtable.role == role)
  rows = current.db(query).select(rtable.id)
  for row in rows:
   pr_remove_from_role(row.id, affiliate_pe)
 return

def pr_remove_affiliation ( master , affiliate , role = None ) : master_pe = pr_get_pe_id ( master ) affiliate_pe = pr_get_pe_id ( affiliate ) if affiliate_pe : s3db = current . s3db atable = s3db . pr_affiliation rtable = s3db . pr_role query = ( ( atable . pe_id == affiliate_pe ) & ( atable . role_id == rtable . id ) ) if master_pe : query &= ( rtable . pe_id == master_pe ) if role : query &= ( rtable . role == role ) rows = current . db ( query ) . select ( rtable . id ) for row in rows : pr_remove_from_role ( row . id , affiliate_pe ) return
remove affiliation records .