Add a detail view for purchase orders

This commit is contained in:
Oliver Walters 2019-06-05 00:17:25 +10:00
parent 7bca9cc7af
commit c82d5482aa
4 changed files with 27 additions and 1 deletions

View File

@ -0,0 +1,9 @@
{% extends "base.html" %}
{% block content %}
Purchase Order: {{ order.reference }}
<br><hr>
Description: {{ order.description }}
{% endblock %}

View File

@ -17,7 +17,7 @@
{% for order in orders %}
<tr>
<td>{% include "hover_image.html" with image=order.supplier.image hover=True %}<a href="{{ order.supplier.get_absolute_url }}">{{ order.supplier.name }}</a></td>
<td>{{ order }}</td>
<td><a href="{% url 'purchase-order-detail' order.id %}">{{ order }}</a></td>
<td>{{ order.description }}</td>
<td>{% include "order/order_status.html" %}</td>
</tr>

View File

@ -9,8 +9,16 @@ from django.conf.urls import url, include
from . import views
purchase_order_detail_urls = [
url(r'^.*$', views.PurchaseOrderDetail.as_view(), name='purchase-order-detail'),
]
purchase_order_urls = [
# Display detail view for a single purchase order
url(r'^(?P<pk>\d+)/', include(purchase_order_detail_urls)),
# Display complete list of purchase orders
url(r'^.*$', views.PurchaseOrderIndex.as_view(), name='purchase-order-index'),
]

View File

@ -13,6 +13,7 @@ from InvenTree.status_codes import OrderStatus
class PurchaseOrderIndex(ListView):
""" List view for all purchase orders """
model = PurchaseOrder
template_name = 'order/purchase_orders.html'
@ -24,3 +25,11 @@ class PurchaseOrderIndex(ListView):
ctx['OrderStatus'] = OrderStatus
return ctx
class PurchaseOrderDetail(DetailView):
""" Detail view for a PurchaseOrder object """
context_object_name = 'order'
queryset = PurchaseOrder.objects.all().prefetch_related('lines')
template_name = 'order/purchase_order_detail.html'