Filter API by overdue status

This commit is contained in:
Oliver Walters 2020-12-18 12:40:47 +11:00
parent b21c6f0b99
commit c34196538b
5 changed files with 41 additions and 2 deletions

View File

@ -266,6 +266,17 @@ class SOList(generics.ListCreateAPIView):
else:
queryset = queryset.exclude(status__in=SalesOrderStatus.OPEN)
# Filter by 'overdue' status
overdue = params.get('overdue', None)
if overdue is not None:
overdue = str2bool(overdue)
if overdue:
queryset = queryset.filter(SalesOrder.OVERDUE_FILTER)
else:
queryset = queryset.exclude(SalesOrder.OVERDUE_FILTER)
status = params.get('status', None)
if status is not None:

View File

@ -128,6 +128,13 @@ class EditSalesOrderForm(HelperForm):
super().__init__(*args, **kwargs)
# TODO: Improve this using a better date picker
target_date = forms.DateField(
widget=forms.DateInput(
attrs={'type': 'date'},
)
)
class Meta:
model = SalesOrder
fields = [
@ -135,6 +142,7 @@ class EditSalesOrderForm(HelperForm):
'customer',
'customer_reference',
'description',
'target_date',
'link'
]

View File

@ -188,7 +188,6 @@ class SalesOrderSerializer(InvenTreeModelSerializer):
fields = [
'pk',
'shipment_date',
'creation_date',
'customer',
'customer_detail',
@ -202,6 +201,7 @@ class SalesOrderSerializer(InvenTreeModelSerializer):
'status',
'status_text',
'shipment_date',
'target_date',
]
read_only_fields = [

View File

@ -37,6 +37,9 @@ src="{% static 'img/blank_image.png' %}"
</h3>
<h3>
{% sales_order_status_label order.status large=True %}
{% if order.is_overdue %}
<span class='label label-large label-large-red'>{% trans "Overdue" %}</span>
{% endif %}
</h3>
<hr>
<p>{{ order.description }}</p>
@ -74,7 +77,12 @@ src="{% static 'img/blank_image.png' %}"
<tr>
<td><span class='fas fa-info'></span></td>
<td>{% trans "Order Status" %}</td>
<td>{% sales_order_status_label order.status %}</td>
<td>
{% sales_order_status_label order.status %}
{% if order.is_overdue %}
<span class='label label-red'>{% trans "Overdue" %}</span>
{% endif %}
</td>
</tr>
<tr>
<td><span class='fas fa-building'></span></td>
@ -100,6 +108,13 @@ src="{% static 'img/blank_image.png' %}"
<td>{% trans "Created" %}</td>
<td>{{ order.creation_date }}<span class='badge'>{{ order.created_by }}</span></td>
</tr>
{% if order.target_date %}
<tr>
<td><span class='fas fa-calendar-alt'></span></td>
<td>{% trans "Target Date" %}</td>
<td>{{ order.target_date }}</td>
</tr>
{% endif %}
{% if order.shipment_date %}
<tr>
<td><span class='fas fa-truck'></span></td>

View File

@ -275,6 +275,11 @@ function loadSalesOrderTable(table, options) {
field: 'creation_date',
title: '{% trans "Creation Date" %}',
},
{
sortable: true,
field: 'target_date',
title: '{% trans "Target Date" %}',
},
{
sortable: true,
field: 'shipment_date',