2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-18 04:55:44 +00:00

Add order status field

- Display status field in PurchaseOrder list view
This commit is contained in:
Oliver Walters
2019-06-04 23:09:51 +10:00
parent da53de844a
commit 76a72be926
11 changed files with 112 additions and 12 deletions

View File

@ -17,6 +17,8 @@ from django.urls import reverse
from django.conf import settings
from django.contrib.staticfiles.templatetags.staticfiles import static
from InvenTree.status_codes import OrderStatus
def rename_company_image(instance, filename):
""" Function to rename a company image after upload
@ -128,6 +130,26 @@ class Company(models.Model):
stock = apps.get_model('stock', 'StockItem')
return stock.objects.filter(supplier_part__supplier=self.id).count()
def outstanding_purchase_orders(self):
""" Return purchase orders which are 'outstanding' """
return self.purchase_orders.filter(status__in=[
OrderStatus.PENDING,
OrderStatus.PLACED
])
def complete_purchase_orders(self):
return self.purchase_orders.filter(status=OrderStatus.COMPLETE)
def failed_purchase_orders(self):
""" Return any purchase orders which were not successful """
return self.purchase_orders.filter(status__in=[
OrderStatus.CANCELLED,
OrderStatus.LOST,
OrderStatus.RETURNED
])
class Contact(models.Model):
""" A Contact represents a person who works at a particular company.

View File

@ -6,7 +6,7 @@
<div class='row'>
<div class='col-sm-6'>
<h3>Company Details</h3>
<h4>Company Details</h4>
</div>
<div class='col-sm-6'>
<h3>

View File

@ -4,7 +4,7 @@
{% include 'company/tabs.html' with tab='parts' %}
<h3>Supplier Parts</h3>
<h4>Supplier Parts</h4>
<div id='button-toolbar'>
<button class="btn btn-success" id='part-create'>New Supplier Part</button>

View File

@ -4,4 +4,17 @@
{% include 'company/tabs.html' with tab='po' %}
<h4>Purchase Orders</h4>
<table class='table table-striped table-condensed' id='po-table'>
<tr>
<th>Reference</th>
<th>Description</th>
<th>Status</th>
</tr>
{% 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 %}
</table>
{% endblock %}

View File

@ -5,7 +5,7 @@
{% include "company/tabs.html" with tab='stock' %}
<h3>Supplier Stock</h3>
<h4>Supplier Stock</h4>
{% include "stock_table.html" %}

View File

@ -1,13 +0,0 @@
{% if order.status == order.PENDING %}
<span class='label label-info'>
{% elif order.status == order.PLACED %}
<span class='label label-primary'>
{% elif order.status == order.RECEIVED %}
<span class='label label-success'>
{% elif order.status == order.CANCELLED %}
<span class='label label-warning'>
{% else %}
<span class='label label-danger'>
{% endif %}
{{ order.get_status_display }}
</span>

View File

@ -0,0 +1,7 @@
{% for order in orders %}
<tr>
<td>{{ order }}</td>
<td>{{ order.description }}</td>
<td>{% include "order/order_status.html" with order=order %}</td>
</tr>
{% endfor %}