(self, fall_back_to_next=False, commit=True)
Resets primary location to next available location from assigned_location_ids.
            If there are no more locations in assigned_location_ids,
            then the primary location and user data are cleared

            If fall_back_to_next is True, primary location is not set to next but cleared.
            This option exists only to be backwards compatible when user can only have one location
Resets primary location to next available location from assigned_location_ids.
            If there are no more locations in assigned_location_ids,
            then the primary location and user data are cleared
Resets primary location to next available location from assigned_location_ids . If there are no more locations in assigned_location_ids then the primary location and user data are cleared
def unset_location(self, fall_back_to_next=False, commit=True):
        """
        Resets primary location to next available location from assigned_location_ids.
            If there are no more locations in assigned_location_ids,
            then the primary location and user data are cleared

            If fall_back_to_next is True, primary location is not set to next but cleared.
            This option exists only to be backwards compatible when user can only have one location
        """
        from corehq.apps.fixtures.models import UserFixtureType
        from corehq.apps.locations.models import SQLLocation
        old_primary_location_id = self.location_id
        if old_primary_location_id:
            self._remove_location_from_user(old_primary_location_id)

        if self.assigned_location_ids:
            self.update_metadata({'commcare_location_ids': user_location_data(self.assigned_location_ids)})
        elif self.metadata.get('commcare_location_ids'):
            self.pop_metadata('commcare_location_ids')

        if self.assigned_location_ids and fall_back_to_next:
            new_primary_location_id = self.assigned_location_ids[0]
            self.set_location(SQLLocation.objects.get(location_id=new_primary_location_id))
        else:
            self.pop_metadata('commcare_location_id', None)
            self.pop_metadata('commtrack-supply-point', None)
            self.pop_metadata('commcare_primary_case_sharing_id', None)
            self.location_id = None
            self.clear_location_delegates()
            self.update_fixture_status(UserFixtureType.LOCATION)
            self.get_domain_membership(self.domain).location_id = None
            self.get_sql_location.reset_cache(self)
            if commit:
                self.save()
def unset_location ( self , fall_back_to_next = False , commit = True ) : from corehq . apps . fixtures . models import UserFixtureType from corehq . apps . locations . models import SQLLocation old_primary_location_id = self . location_id if old_primary_location_id : self . _remove_location_from_user ( old_primary_location_id ) if self . assigned_location_ids : self . update_metadata ( { 'commcare_location_ids' : user_location_data ( self . assigned_location_ids ) } ) elif self . metadata . get ( 'commcare_location_ids' ) : self . pop_metadata ( 'commcare_location_ids' ) if self . assigned_location_ids and fall_back_to_next : new_primary_location_id = self . assigned_location_ids [ 0 ] self . set_location ( SQLLocation . objects . get ( location_id = new_primary_location_id ) ) else : self . pop_metadata ( 'commcare_location_id' , None ) self . pop_metadata ( 'commtrack-supply-point' , None ) self . pop_metadata ( 'commcare_primary_case_sharing_id' , None ) self . location_id = None self . clear_location_delegates ( ) self . update_fixture_status ( UserFixtureType . LOCATION ) self . get_domain_membership ( self . domain ) . location_id = None self . get_sql_location . reset_cache ( self ) if commit : self . save ( )