def supply_item_entity_category(row):
 if hasattr(row, 'supply_item_entity'):
  row = row.supply_item_entity
 else:
  return None
 try:
  item_id = row.item_id
 except AttributeError:
  return None
 table = current.s3db.supply_item
 query = (table.id == item_id)
 record = current.db(query).select(table.item_category_id, limitby=(0, 1)).first()
 if record:
  return table.item_category_id.represent(record.item_category_id)
 else:
  return current.messages['NONE']

def supply_item_entity_category ( row ) : if hasattr ( row , 'supply_item_entity' ) : row = row . supply_item_entity else : return None try : item_id = row . item_id except AttributeError : return None table = current . s3db . supply_item query = ( table . id == item_id ) record = current . db ( query ) . select ( table . item_category_id , limitby = ( 0 , 1 ) ) . first ( ) if record : return table . item_category_id . represent ( record . item_category_id ) else : return current . messages [ 'NONE' ]
virtual field: category .