From 5bb08053e019c62158e4d451e0318eff5110f247 Mon Sep 17 00:00:00 2001 From: James Newlands Date: Wed, 18 Apr 2018 00:38:06 +1000 Subject: [PATCH] Added table of orders and details for each order showing table of lines --- .../migrations/0010_auto_20180418_0028.py | 21 ++++++ .../migrations/0002_auto_20180418_0028.py | 66 +++++++++++++++++++ InvenTree/customer/models.py | 3 +- .../templates/customer/order_detail.html | 5 ++ .../templates/customer/order_index.html | 25 ++++--- .../templates/customer/order_lines_table.html | 14 ++++ .../templates/customer/orders_table.html | 14 ++++ .../migrations/0014_auto_20180418_0028.py | 21 ++++++ 8 files changed, 154 insertions(+), 15 deletions(-) create mode 100644 InvenTree/build/migrations/0010_auto_20180418_0028.py create mode 100644 InvenTree/customer/migrations/0002_auto_20180418_0028.py create mode 100644 InvenTree/customer/templates/customer/order_lines_table.html create mode 100644 InvenTree/customer/templates/customer/orders_table.html create mode 100644 InvenTree/stock/migrations/0014_auto_20180418_0028.py diff --git a/InvenTree/build/migrations/0010_auto_20180418_0028.py b/InvenTree/build/migrations/0010_auto_20180418_0028.py new file mode 100644 index 0000000000..a75488c11b --- /dev/null +++ b/InvenTree/build/migrations/0010_auto_20180418_0028.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11 on 2018-04-17 14:28 +from __future__ import unicode_literals + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('build', '0009_auto_20180417_1316'), + ] + + operations = [ + migrations.AlterField( + model_name='build', + name='status', + field=models.PositiveIntegerField(choices=[(10, 'Pending'), (20, 'Holding'), (30, 'Cancelled'), (40, 'Complete')], default=10, validators=[django.core.validators.MinValueValidator(0)]), + ), + ] diff --git a/InvenTree/customer/migrations/0002_auto_20180418_0028.py b/InvenTree/customer/migrations/0002_auto_20180418_0028.py new file mode 100644 index 0000000000..42e935f672 --- /dev/null +++ b/InvenTree/customer/migrations/0002_auto_20180418_0028.py @@ -0,0 +1,66 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11 on 2018-04-17 14:28 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('customer', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='customerorder', + name='created_date', + field=models.DateField(auto_now_add=True, help_text='Date order entered in system'), + ), + migrations.AlterField( + model_name='customerorder', + name='customer', + field=models.ForeignKey(blank=True, help_text='Customer that placed this order', null=True, on_delete=django.db.models.deletion.SET_NULL, to='customer.Customer'), + ), + migrations.AlterField( + model_name='customerorder', + name='customer_ref', + field=models.CharField(blank=True, default='', max_length=100), + ), + migrations.AlterField( + model_name='customerorder', + name='issued_date', + field=models.DateField(blank=True, help_text='Date order issued by customer'), + ), + migrations.AlterField( + model_name='customerorder', + name='notes', + field=models.TextField(blank=True, default='', help_text='Order notes'), + ), + migrations.AlterField( + model_name='customerorderline', + name='customer_order', + field=models.ForeignKey(help_text='Order this line belongs to', on_delete=django.db.models.deletion.CASCADE, to='customer.CustomerOrder'), + ), + migrations.AlterField( + model_name='customerorderline', + name='line_number', + field=models.PositiveIntegerField(default=0, help_text='Line number'), + ), + migrations.AlterField( + model_name='customerorderline', + name='notes', + field=models.TextField(blank=True, help_text='Line notes'), + ), + migrations.AlterField( + model_name='customerorderline', + name='part', + field=models.ForeignKey(blank=True, help_text='Part', on_delete=django.db.models.deletion.CASCADE, related_name='order_lines', to='part.Part'), + ), + migrations.AlterField( + model_name='customerorderline', + name='quantity', + field=models.PositiveIntegerField(blank=True, help_text='Quantity of part'), + ), + ] diff --git a/InvenTree/customer/models.py b/InvenTree/customer/models.py index 4b16ef634b..4f8c11879a 100644 --- a/InvenTree/customer/models.py +++ b/InvenTree/customer/models.py @@ -57,7 +57,8 @@ class CustomerOrderLine(models.Model): ] # Point to a specific customer order - customer_order = models.ForeignKey(CustomerOrder, on_delete=models.CASCADE, help_text="Order this line belongs to") + customer_order = models.ForeignKey(CustomerOrder, on_delete=models.CASCADE, help_text="Order this line belongs to", + related_name='lines') line_number = models.PositiveIntegerField(default=0, help_text="Line number") diff --git a/InvenTree/customer/templates/customer/order_detail.html b/InvenTree/customer/templates/customer/order_detail.html index 9cd5dfea90..8ccb144cff 100644 --- a/InvenTree/customer/templates/customer/order_detail.html +++ b/InvenTree/customer/templates/customer/order_detail.html @@ -2,4 +2,9 @@ {% block content %} +

Order Summary

+{{ order.internal_ref }} +

Order Detail

+{% include "customer/order_lines_table.html" with order_lines=order.lines.all %} + {% endblock %} \ No newline at end of file diff --git a/InvenTree/customer/templates/customer/order_index.html b/InvenTree/customer/templates/customer/order_index.html index c33d615951..b0b05bc00b 100644 --- a/InvenTree/customer/templates/customer/order_index.html +++ b/InvenTree/customer/templates/customer/order_index.html @@ -1,14 +1,11 @@ - - - - - - - {% for order in customer_orders %} - - - - - - {% endfor %} -
Internal RefCustomerCustomer Ref
{{ order.internal_ref }}{{ order.customer }}{{ order.customer_ref }}
\ No newline at end of file +{% extends "base.html" %} +{% load static %} + +{% block content %} + +{% if customer_orders.all|length > 0 %} +

Customer Orders

+ {% include "customer/orders_table.html" with customer_orders=customer_orders %} +{% endif %} + +{% endblock %} \ No newline at end of file diff --git a/InvenTree/customer/templates/customer/order_lines_table.html b/InvenTree/customer/templates/customer/order_lines_table.html new file mode 100644 index 0000000000..d115c35a8a --- /dev/null +++ b/InvenTree/customer/templates/customer/order_lines_table.html @@ -0,0 +1,14 @@ + + + + + + + {% for line in order_lines %} + + + + + + {% endfor %} +
Line NumberPartQuantity
{{ line.line_number }}{{ line.part }}{{ line.quantity }}
\ No newline at end of file diff --git a/InvenTree/customer/templates/customer/orders_table.html b/InvenTree/customer/templates/customer/orders_table.html new file mode 100644 index 0000000000..4eb5711395 --- /dev/null +++ b/InvenTree/customer/templates/customer/orders_table.html @@ -0,0 +1,14 @@ + + + + + + + {% for order in customer_orders %} + + + + + + {% endfor %} +
Internal RefCustomerCustomer Ref
{{ order.internal_ref }}{{ order.customer }}{{ order.customer_ref }}
\ No newline at end of file diff --git a/InvenTree/stock/migrations/0014_auto_20180418_0028.py b/InvenTree/stock/migrations/0014_auto_20180418_0028.py new file mode 100644 index 0000000000..c2056b0d7e --- /dev/null +++ b/InvenTree/stock/migrations/0014_auto_20180418_0028.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11 on 2018-04-17 14:28 +from __future__ import unicode_literals + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('stock', '0013_auto_20180417_1337'), + ] + + operations = [ + migrations.AlterField( + model_name='stockitem', + name='status', + field=models.PositiveIntegerField(choices=[(10, 'OK'), (50, 'Attention needed'), (55, 'Damaged'), (60, 'Destroyed')], default=10, validators=[django.core.validators.MinValueValidator(0)]), + ), + ]