Maybe the line 213 is wrong: else: location_ids = context['location'] if location defined in the context is neither a list nor an int
Maybe the line 213 is wrong:
location_ ids = context['location']
else:
if location defined in the context is neither a list nor an int