Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Create invoice model

Tomasz Szymański9b6962834536
diff --git a/saleor/order/migrations/0079_invoice.py b/saleor/order/migrations/0079_invoice.py
new file mode 100644
index 0000000000..3f62592eac
--- /dev/null
+++ b/saleor/order/migrations/0079_invoice.py
@@ -0,0 +1,37 @@
+# Generated by Django 2.2.10 on 2020-03-02 10:03
+
+import django.db.models.deletion
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ("order", "0078_auto_20200221_0257"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="Invoice",
+ fields=[
+ (
+ "id",
+ models.AutoField(
+ auto_created=True,
+ primary_key=True,
+ serialize=False,
+ verbose_name="ID",
+ ),
+ ),
+ ("number", models.CharField(max_length=64)),
+ ("created", models.DateTimeField(auto_now_add=True)),
+ ("url", models.URLField(max_length=256)),
+ (
+ "order",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, to="order.Order"
+ ),
+ ),
+ ],
+ ),
+ ]
diff --git a/saleor/order/models.py b/saleor/order/models.py
index d0b98f2cc7..54e6038fb8 100644
--- a/saleor/order/models.py
+++ b/saleor/order/models.py
@@ -500,3 +500,10 @@ class OrderEvent(models.Model):
def __repr__(self):
return f"{self.__class__.__name__}(type={self.type!r}, user={self.user!r})"
+
+
+class Invoice(models.Model):
+ order = models.ForeignKey(Order, on_delete=models.CASCADE)
+ number = models.CharField(max_length=64)
+ created = models.DateTimeField(auto_now_add=True)
+ url = models.URLField(max_length=256)