'Custom lookup method for organisation rows, does a
join with the projects and locations. Parameters
key and fields are not used, but are kept for API
compatiblity reasons.
@param values: the project_location IDs'

def custom_lookup_rows(self, key, values, fields=None):

    db = current.db
    ltable = current.s3db.project_location
    gtable = db.gis_location
    fields = [ltable.id, gtable.name, gtable.level, gtable.L0, gtable.L1, gtable.L2, gtable.L3, gtable.L4, gtable.L5]
    if (len(values) == 1):
        query = ((ltable.id == values[0]) & (ltable.location_id == gtable.id))
        limitby = (0, 1)
    else:
        query = (ltable.id.belongs(values) & (ltable.location_id == gtable.id))
        limitby = None
    if (not self.community):
        ptable = db.project_project
        query &= (ltable.project_id == ptable.id)
        fields.append(ptable.name)
        if self.use_codes:
            fields.append(ptable.code)
    rows = db(query).select(limitby=limitby, *fields)
    self.queries += 1
    return rows
