From 8b8191e16d1e3f64bdbaf8be6c251d690dbf4106 Mon Sep 17 00:00:00 2001 From: Patrick Welzel Date: Wed, 22 Aug 2018 15:41:24 +0200 Subject: [PATCH] add custom address field to shop.models.Order and invoice template --- .../migrations/0055_order_customer_address.py | 18 ++++++++++++++++++ src/shop/models.py | 6 ++++++ src/shop/templates/pdf/invoice.html | 5 +++++ 3 files changed, 29 insertions(+) create mode 100644 src/shop/migrations/0055_order_customer_address.py diff --git a/src/shop/migrations/0055_order_customer_address.py b/src/shop/migrations/0055_order_customer_address.py new file mode 100644 index 00000000..2720cf33 --- /dev/null +++ b/src/shop/migrations/0055_order_customer_address.py @@ -0,0 +1,18 @@ +# Generated by Django 2.1 on 2018-08-22 13:18 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('shop', '0054_auto_20180415_1159'), + ] + + operations = [ + migrations.AddField( + model_name='order', + name='customer_address', + field=models.TextField(blank=True, help_text='The additional customer address for this order'), + ), + ] diff --git a/src/shop/models.py b/src/shop/models.py index adf97027..3aad4399 100644 --- a/src/shop/models.py +++ b/src/shop/models.py @@ -87,6 +87,12 @@ class Order(CreatedUpdatedModel): default=True, ) + customer_address = models.TextField( + help_text=_('The additional customer address for this order'), + blank=True + ) + + CREDIT_CARD = 'credit_card' BLOCKCHAIN = 'blockchain' BANK_TRANSFER = 'bank_transfer' diff --git a/src/shop/templates/pdf/invoice.html b/src/shop/templates/pdf/invoice.html index 65515620..f95e05a7 100644 --- a/src/shop/templates/pdf/invoice.html +++ b/src/shop/templates/pdf/invoice.html @@ -14,7 +14,12 @@ +{% if invoice.order.customer_address %} +

CUSTOMER

+

{{ invoice.order.customer_address|linebreaks }}

+{% else %}

Customer: {{ invoice.order.user.email }}

+{% endif %}

INVOICE