def store_assign_analysis_code(apps, schema_editor):
    """Assign the Internet AalysisCode to all existing sales"""
    sale_analysis_code_class = apps.get_model('Store', 'SaleAnalysisCode')
    sale_class = apps.get_model('Store', 'Sale')
    sale_analysis_code = sale_analysis_code_class.objects.get_or_create(name
        =u'Internet')[0]
    for sale in sale_class.objects.filter(analysis_code__isnull=True):
        sale.analysis_code = sale_analysis_code
        sale.save()
