def _supply_point_from_location(loc, type, parent=None): try: sp = SupplyPoint.objects.get(location=loc, type=type) except SupplyPoint.DoesNotExist: sp = SupplyPoint(location=loc) sp.name = loc.name sp.active = True sp.type = type sp.code = loc.code sp.supplied_by = parent sp.save() return sp
def supply_point_from_location(loc, type, parent=None): """ This utility is used by the loaders to create supply points from locations """ try: sp = SupplyPoint.objects.get(location=loc, type=type) except SupplyPoint.DoesNotExist: sp = SupplyPoint(location=loc) sp.name = loc.name # sp.active = True sp.type = type sp.code = loc.code sp.supplied_by = parent try: sp.save() except: print sp raise return sp