Use a choice field for invoice address countries

This commit is contained in:
Raphael Michel
2017-07-19 12:08:18 +02:00
parent f8ed21c819
commit d2b0e7209f
13 changed files with 96 additions and 14 deletions

View File

@@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.2 on 2017-07-19 09:10
from __future__ import unicode_literals
import django_countries
from django.db import migrations, models
def fwd(app, schema_editor):
InvoiceAddress = app.get_model('pretixbase', 'InvoiceAddress')
for ia in InvoiceAddress.objects.all():
if ia.company or ia.vat_id:
ia.is_business = True
ia.save()
class Migration(migrations.Migration):
dependencies = [
('pretixbase', '0069_invoice_prefix'),
]
operations = [
migrations.RenameField(
model_name='invoiceaddress',
old_name='country',
new_name='country_old',
),
migrations.AddField(
model_name='invoiceaddress',
name='country',
field=django_countries.fields.CountryField(default='', max_length=2, verbose_name='Country'),
preserve_default=False,
),
migrations.AddField(
model_name='invoiceaddress',
name='is_business',
field=models.BooleanField(default=False, verbose_name='Business customer'),
),
migrations.RunPython(
fwd, migrations.RunPython.noop
),
]