def has_match(row, linked_doctypes, doctype_match_filters, ref_doctype, if_owner, columns_dict, user):
 resultant_match = True
 if (not row):
  return resultant_match
 for (doctype, filter_list) in doctype_match_filters.items():
  matched_for_doctype = False
  if ((doctype == ref_doctype) and if_owner):
   idx = linked_doctypes.get(u'User')
   if ((idx is not None) and (row[idx] == user) and (columns_dict[idx] == columns_dict.get(u'owner'))):
    matched_for_doctype = True
  if (not matched_for_doctype):
   for match_filters in filter_list:
    match = True
    for (dt, idx) in linked_doctypes.items():
     if ((dt == u'User') and (columns_dict[idx] == columns_dict.get(u'owner'))):
      continue
     if ((dt in match_filters) and (row[idx] not in match_filters[dt])):
      match = False
      break
    matched_for_doctype = (matched_for_doctype or match)
    if matched_for_doctype:
     break
  resultant_match = (resultant_match and matched_for_doctype)
  if (not resultant_match):
   break
 return resultant_match

def has_match ( row , linked_doctypes , doctype_match_filters , ref_doctype , if_owner , columns_dict , user ) : resultant_match = True if ( not row ) : return resultant_match for ( doctype , filter_list ) in doctype_match_filters . items ( ) : matched_for_doctype = False if ( ( doctype == ref_doctype ) and if_owner ) : idx = linked_doctypes . get ( u'User' ) if ( ( idx is not None ) and ( row [ idx ] == user ) and ( columns_dict [ idx ] == columns_dict . get ( u'owner' ) ) ) : matched_for_doctype = True if ( not matched_for_doctype ) : for match_filters in filter_list : match = True for ( dt , idx ) in linked_doctypes . items ( ) : if ( ( dt == u'User' ) and ( columns_dict [ idx ] == columns_dict . get ( u'owner' ) ) ) : continue if ( ( dt in match_filters ) and ( row [ idx ] not in match_filters [ dt ] ) ) : match = False break matched_for_doctype = ( matched_for_doctype or match ) if matched_for_doctype : break resultant_match = ( resultant_match and matched_for_doctype ) if ( not resultant_match ) : break return resultant_match
returns true if after evaluating permissions for each linked doctype - there is an owner match for the ref_doctype - and there is a user permission match for all linked doctypes returns true if the row is empty note: each doctype could have multiple conflicting user permission doctypes .