mirror of
https://github.com/pretix/pretix.git
synced 2026-05-04 15:04:03 +00:00
Use a choice field for invoice address countries
This commit is contained in:
@@ -100,7 +100,7 @@ class OrderListExporter(BaseExporter):
|
||||
order.invoice_address.street,
|
||||
order.invoice_address.zipcode,
|
||||
order.invoice_address.city,
|
||||
order.invoice_address.country,
|
||||
order.invoice_address.country if order.invoice_address.country else order.invoice_address.country_old,
|
||||
order.invoice_address.vat_id,
|
||||
]
|
||||
except InvoiceAddress.DoesNotExist:
|
||||
|
||||
43
src/pretix/base/migrations/0070_auto_20170719_0910.py
Normal file
43
src/pretix/base/migrations/0070_auto_20170719_0910.py
Normal 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
|
||||
),
|
||||
]
|
||||
@@ -19,6 +19,7 @@ from django.utils.html import escape
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils.timezone import make_aware, now
|
||||
from django.utils.translation import pgettext_lazy, ugettext_lazy as _
|
||||
from django_countries.fields import CountryField
|
||||
|
||||
from pretix.base.reldate import RelativeDateWrapper
|
||||
|
||||
@@ -727,13 +728,15 @@ class CartPosition(AbstractPosition):
|
||||
|
||||
class InvoiceAddress(models.Model):
|
||||
last_modified = models.DateTimeField(auto_now=True)
|
||||
is_business = models.BooleanField(default=False, verbose_name=_('Business customer'))
|
||||
order = models.OneToOneField(Order, null=True, blank=True, related_name='invoice_address')
|
||||
company = models.CharField(max_length=255, blank=True, verbose_name=_('Company name'))
|
||||
name = models.CharField(max_length=255, verbose_name=_('Full name'), blank=True)
|
||||
street = models.TextField(verbose_name=_('Address'), blank=False)
|
||||
zipcode = models.CharField(max_length=30, verbose_name=_('ZIP code'), blank=False)
|
||||
city = models.CharField(max_length=255, verbose_name=_('City'), blank=False)
|
||||
country = models.CharField(max_length=255, verbose_name=_('Country'), blank=False)
|
||||
country_old = models.CharField(max_length=255, verbose_name=_('Country'), blank=False)
|
||||
country = CountryField(verbose_name=_('Country'), blank=False, blank_label=_('Select country'))
|
||||
vat_id = models.CharField(max_length=255, blank=True, verbose_name=_('VAT ID'))
|
||||
|
||||
|
||||
|
||||
@@ -37,8 +37,11 @@ def build_invoice(invoice: Invoice) -> Invoice:
|
||||
{i.name}
|
||||
{i.street}
|
||||
{i.zipcode} {i.city}
|
||||
{i.country}""")
|
||||
invoice.invoice_to = addr_template.format(i=invoice.order.invoice_address).strip()
|
||||
{country}""")
|
||||
invoice.invoice_to = addr_template.format(
|
||||
i=invoice.order.invoice_address,
|
||||
country=invoice.order.invoice_address.country.name if invoice.order.invoice_address.country else invoice.order.invoice_address.country_old
|
||||
).strip()
|
||||
if invoice.order.invoice_address.vat_id:
|
||||
invoice.invoice_to += "\n" + pgettext("invoice", "VAT-ID: %s") % invoice.order.invoice_address.vat_id
|
||||
except InvoiceAddress.DoesNotExist:
|
||||
|
||||
Reference in New Issue
Block a user