Add detail view for SalesOrder

This commit is contained in:
Oliver Walters 2020-04-20 20:59:14 +10:00
parent 1ebf26ab7c
commit 47ada25315
10 changed files with 168 additions and 4 deletions

View File

@ -6,7 +6,7 @@
{% load status_codes %} {% load status_codes %}
{% block page_title %} {% block page_title %}
InvenTree | {{ order }} InvenTree | {% trans "Purchase Order" %}
{% endblock %} {% endblock %}
{% block content %} {% block content %}

View File

@ -7,7 +7,7 @@
{% block details %} {% block details %}
{% include 'order/tabs.html' with tab='notes' %} {% include 'order/po_tabs.html' with tab='notes' %}
{% if editing %} {% if editing %}
<h4>{% trans "Order Notes" %}</h4> <h4>{% trans "Order Notes" %}</h4>

View File

@ -6,7 +6,7 @@
{% block details %} {% block details %}
{% include 'order/tabs.html' with tab='attachments' %} {% include 'order/po_tabs.html' with tab='attachments' %}
<h4>{% trans "Purchase Order Attachments" %} <h4>{% trans "Purchase Order Attachments" %}

View File

@ -7,7 +7,7 @@
{% block details %} {% block details %}
{% include 'order/tabs.html' with tab='details' %} {% include 'order/po_tabs.html' with tab='details' %}
<hr> <hr>

View File

@ -0,0 +1,110 @@
{% extends "base.html" %}
{% load i18n %}
{% load static %}
{% load inventree_extras %}
{% load status_codes %}
{% block page_title %}
InvenTree | {% trans "Sales Order" %}
{% endblock %}
{% block content %}
<div class='row'>
<div class='col-sm-6'>
<div class='media'>
<div class='media-left'>
<img class='part-thumb'
{% if order.customer.image %}
src="{{ order.customer.image.url }}"
{% else %}
src="{% static 'img/blank_image.png' %}"
{% endif %}
/>
</div>
<div class='media-body'>
<h4>{{ order }}</h4>
<p>{{ order.description }}</p>
<p>
<div class='btn-row'>
<div class='btn-group'>
<button type='button' class='btn btn-default btn-glyph' id='edit-order' title='Edit order information'>
<span class='glyphicon glyphicon-edit'></span>
</button>
</div>
</div>
</p>
</div>
</div>
</div>
<div class='col-sm-6'>
<h4>{% trans "Sales Order Details" %}</h4>
<table class='table'>
<col width='25'>
<tr>
<td><span class='fas fa-hashtag'></span></td>
<td>{% trans "Order Reference" %}</td>
<td>{{ order.reference }}</td>
</tr>
<tr>
<td><span class='fas fa-info'></span></td>
<td>{% trans "Order Status" %}</td>
<td>{% order_status order.status %}</td>
</tr>
<tr>
<td><span class='fas fa-building'></span></td>
<td>{% trans "Customer" %}</td>
<td><a href="{% url 'company-detail' order.customer.id %}">{{ order.customer.name }}</a></td>
</tr>
{% if order.customer_reference %}
<tr>
<td><span class='fas fa-hashtag'></span></td>
<td>{% trans "Customer Reference" %}</td>
<td>{{ order.customer_reference }}</td>
</tr>
{% endif %}
{% if order.link %}
<tr>
<td><span class='fas fa-link'></span></td>
<td>External Link</td>
<td><a href="{{ order.link }}">{{ order.link }}</a></td>
</tr>
{% endif %}
<tr>
<td><span class='fas fa-calendar-alt'></span></td>
<td>{% trans "Created" %}</td>
<td>{{ order.creation_date }}<span class='badge'>{{ order.created_by }}</span></td>
</tr>
{% if order.issue_date %}
<tr>
<td><span class='fas fa-calendar-alt'></span></td>
<td>{% trans "Issued" %}</td>
<td>{{ order.issue_date }}</td>
</tr>
{% endif %}
{% if order.status == OrderStatus.COMPLETE %}
<tr>
<td><span class='fas fa-calendar-alt'></span></td>
<td>{% trans "Received" %}</td>
<td>{{ order.complete_date }}<span class='badge'>{{ order.received_by }}</span></td>
</tr>
{% endif %}
</table>
</div>
</div>
<hr>
<div class='container-fluid'>
{% block details %}
<!-- sales order details go here -->
{% endblock %}
</div>
{% endblock %}
{% block js_ready %}
{{ block.super }}
{% endblock %}

View File

@ -0,0 +1,19 @@
{% extends "order/sales_order_base.html" %}
{% load inventree_extras %}
{% load status_codes %}
{% load i18n %}
{% load static %}
{% block details %}
{% include 'order/so_tabs.html' with tab='details' %}
<hr>
{% endblock %}
{% block js_ready %}
{{ block.super }}
{% endblock %}

View File

@ -0,0 +1,17 @@
{% load i18n %}
<ul class='nav nav-tabs'>
<li{% ifequal tab 'details' %} class='active'{% endifequal %}>
<a href="{% url 'po-detail' order.id %}">{% trans "Items" %}</a>
</li>
<li{% if tab == 'attachments' %} class='active'{% endif %}>
<a href="#">{% trans "Attachments" %}
{% if order.attachments.count > 0 %}
<span class='badge'>{{ order.attachments.count }}</span>
{% endif %}
</a>
</li>
<li{% ifequal tab 'notes' %} class='active'{% endifequal %}>
<a href="##">{% trans "Notes" %}{% if order.notes %} <span class='glyphicon glyphicon-small glyphicon-info-sign'></span>{% endif %}</a>
</li>
</ul>

View File

@ -61,7 +61,17 @@ purchase_order_urls = [
url(r'^.*$', views.PurchaseOrderIndex.as_view(), name='po-index'), url(r'^.*$', views.PurchaseOrderIndex.as_view(), name='po-index'),
] ]
sales_order_detail_urls = [
url(r'^.*$', views.SalesOrderDetail.as_view(), name='so-detail'),
]
sales_order_urls = [ sales_order_urls = [
# Display detail view for a single SalesOrder
url(r'^(?P<pk>\d+)/', include(sales_order_detail_urls)),
# Display list of all sales orders
url(r'^.*$', views.SalesOrderIndex.as_view(), name='so-index'), url(r'^.*$', views.SalesOrderIndex.as_view(), name='so-index'),
] ]

View File

@ -78,6 +78,14 @@ class PurchaseOrderDetail(DetailView):
return ctx return ctx
class SalesOrderDetail(DetailView):
""" Detail view for a SalesOrder object """
context_object_name = 'order'
queryset = SalesOrder.objects.all().prefetch_related('lines')
template_name = 'order/sales_order_detail.html'
class PurchaseOrderAttachmentCreate(AjaxCreateView): class PurchaseOrderAttachmentCreate(AjaxCreateView):
""" """
View for creating a new PurchaseOrderAtt View for creating a new PurchaseOrderAtt