from corehq.apps.locations.models import Location
from django.core.management import BaseCommand

from corehq.form_processor.interfaces.supply import SupplyInterface


class Command(BaseCommand):
    help = 'Assign wholesaler case IDs to child cases.'

    def handle(self, *args, **options):
        domain = "colalifezambia"
        interface = SupplyInterface(domain)
        for retailer_location in Location.filter_by_type(domain, "retailer"):
            retailer_case = interface.get_by_location(retailer_location)
            wholesaler_location = retailer_location.parent
            wholesaler_case = interface.get_by_location(
                wholesaler_location
            )
            retailer_case.wholesaler_case_id = wholesaler_case._id
            retailer_case.save()

d25e74e35d110ea6b91d2678c3f0dd871f1ac037
<mask token>


class Command(BaseCommand):
    <mask token>
    <mask token>

<mask token>


class Command(BaseCommand):
    <mask token>

    def handle(self, *args, **options):
        domain = 'colalifezambia'
        interface = SupplyInterface(domain)
        for retailer_location in Location.filter_by_type(domain, 'retailer'):
            retailer_case = interface.get_by_location(retailer_location)
            wholesaler_location = retailer_location.parent
            wholesaler_case = interface.get_by_location(wholesaler_location)
            retailer_case.wholesaler_case_id = wholesaler_case._id
            retailer_case.save()

<mask token>


class Command(BaseCommand):
    help = 'Assign wholesaler case IDs to child cases.'

    def handle(self, *args, **options):
        domain = 'colalifezambia'
        interface = SupplyInterface(domain)
        for retailer_location in Location.filter_by_type(domain, 'retailer'):
            retailer_case = interface.get_by_location(retailer_location)
            wholesaler_location = retailer_location.parent
            wholesaler_case = interface.get_by_location(wholesaler_location)
            retailer_case.wholesaler_case_id = wholesaler_case._id
            retailer_case.save()

from corehq.apps.locations.models import Location
from django.core.management import BaseCommand
from corehq.form_processor.interfaces.supply import SupplyInterface


class Command(BaseCommand):
    help = 'Assign wholesaler case IDs to child cases.'

    def handle(self, *args, **options):
        domain = 'colalifezambia'
        interface = SupplyInterface(domain)
        for retailer_location in Location.filter_by_type(domain, 'retailer'):
            retailer_case = interface.get_by_location(retailer_location)
            wholesaler_location = retailer_location.parent
            wholesaler_case = interface.get_by_location(wholesaler_location)
            retailer_case.wholesaler_case_id = wholesaler_case._id
            retailer_case.save()

from corehq.apps.locations.models import Location
from django.core.management import BaseCommand

from corehq.form_processor.interfaces.supply import SupplyInterface


class Command(BaseCommand):
    help = 'Assign wholesaler case IDs to child cases.'

    def handle(self, *args, **options):
        domain = "colalifezambia"
        interface = SupplyInterface(domain)
        for retailer_location in Location.filter_by_type(domain, "retailer"):
            retailer_case = interface.get_by_location(retailer_location)
            wholesaler_location = retailer_location.parent
            wholesaler_case = interface.get_by_location(
                wholesaler_location
            )
            retailer_case.wholesaler_case_id = wholesaler_case._id
            retailer_case.save()
