From c132f275f5a403da3cdc7fa4099c57bc8e5237db Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 10 Jun 2019 22:43:09 +1000 Subject: [PATCH] Split display of purchase orders by company view --- InvenTree/company/models.py | 10 ++++++ .../company/detail_purchase_orders.html | 18 +++++------ .../company/templates/company/orders.html | 31 ------------------- .../templates/order/po_table_collapse.html | 11 +++++++ 4 files changed, 28 insertions(+), 42 deletions(-) delete mode 100644 InvenTree/company/templates/company/orders.html create mode 100644 InvenTree/order/templates/order/po_table_collapse.html diff --git a/InvenTree/company/models.py b/InvenTree/company/models.py index 069ecb0ad6..4f0e45c2aa 100644 --- a/InvenTree/company/models.py +++ b/InvenTree/company/models.py @@ -135,6 +135,16 @@ class Company(models.Model): """ Return purchase orders which are 'outstanding' """ return self.purchase_orders.filter(status__in=OrderStatus.OPEN) + def closed_purchase_orders(self): + """ Return purchase orders which are not 'outstanding' + + - Complete + - Failed / lost + - Returned + """ + + return self.purchase_orders.exclude(status__in=OrderStatus.OPEN) + def complete_purchase_orders(self): return self.purchase_orders.filter(status=OrderStatus.COMPLETE) diff --git a/InvenTree/company/templates/company/detail_purchase_orders.html b/InvenTree/company/templates/company/detail_purchase_orders.html index 28d7becd1a..0b9882a041 100644 --- a/InvenTree/company/templates/company/detail_purchase_orders.html +++ b/InvenTree/company/templates/company/detail_purchase_orders.html @@ -4,17 +4,13 @@ {% include 'company/tabs.html' with tab='po' %} -

Purchase Orders

+

Open Purchase Orders

+ +{% include "order/po_table.html" with orders=company.outstanding_purchase_orders.all %} + +{% if company.closed_purchase_orders.count > 0 %} +{% include "order/po_table_collapse.html" with title="Closed Orders" orders=company.closed_purchase_orders.all %} +{% endif %} - - - - - - - {% include "company/po_list.html" with orders=company.outstanding_purchase_orders %} - {% include "company/po_list.html" with orders=company.complete_purchase_orders %} - {% include "company/po_list.html" with orders=company.failed_purchase_orders %} -
ReferenceDescriptionStatus
{% endblock %} \ No newline at end of file diff --git a/InvenTree/company/templates/company/orders.html b/InvenTree/company/templates/company/orders.html deleted file mode 100644 index 519035f5c6..0000000000 --- a/InvenTree/company/templates/company/orders.html +++ /dev/null @@ -1,31 +0,0 @@ -{% extends "supplier/supplier_base.html" %} - -{% block details %} - -{% include "supplier/tabs.html" with tab='order' %} - -

Supplier Orders

- - - - - - - - -{% for order in supplier.orders.all %} - - - - - - -{% endfor %} -
ReferenceIssuedDeliveryStatus
{{ order.internal_ref }}{% if order.issued_date %}{{ order.issued_date }}{% endif %}{% if order.delivery_date %}{{ order.delivery_date }}{% endif %}{% include "supplier/order_status.html" with order=order %}
- -
- - - - -{% endblock %} \ No newline at end of file diff --git a/InvenTree/order/templates/order/po_table_collapse.html b/InvenTree/order/templates/order/po_table_collapse.html new file mode 100644 index 0000000000..886e14ce97 --- /dev/null +++ b/InvenTree/order/templates/order/po_table_collapse.html @@ -0,0 +1,11 @@ +{% extends "collapse.html" %} + +{% load static %} + +{% block collapse_title %} +

{{ title }}

+{% endblock %} + +{% block collapse_content %} +{% include "order/po_table.html" %} +{% endblock %} \ No newline at end of file