Add a VIew for receiving purchase order

This commit is contained in:
Oliver Walters 2019-06-15 17:09:25 +10:00
parent 11d9312c45
commit bbd6b15089
4 changed files with 47 additions and 0 deletions

View File

@ -63,6 +63,8 @@ InvenTree | {{ order }}
<button type='button' class='btn btn-primary' id='edit-order'>Edit Order</button>
{% if order.status == OrderStatus.PENDING and order.lines.count > 0 %}
<button type='button' class='btn btn-primary' id='place-order'>Place Order</button>
{% elif order.status == OrderStatus.PLACED %}
<button type='button' class='btn btn-primary' id='receive-order'>Receive Order</button>
{% endif %}
<button type='button' class='btn btn-primary' id='export-order' title='Export order to file'>Export</button>
</div>
@ -159,6 +161,12 @@ $("#edit-order").click(function() {
);
});
$("#receive-order").click(function() {
launchModalForm("{% url 'purchase-order-receive' order.id %}", {
reload: true,
});
});
$("#export-order").click(function() {
location.href = "{% url 'purchase-order-export' order.id %}";
});

View File

@ -0,0 +1,10 @@
{% extends "modal_form.html" %}
{% block form %}
<form method='post' action='' class='js-modal-form' enctype='multipart/form-data'>
{% csrf_token %}
{% load crispy_forms_tags %}
</form>
{% endblock %}

View File

@ -13,6 +13,7 @@ purchase_order_detail_urls = [
url(r'^edit/?', views.PurchaseOrderEdit.as_view(), name='purchase-order-edit'),
url(r'^issue/?', views.PurchaseOrderIssue.as_view(), name='purchase-order-issue'),
url(r'^receive/?', views.PurchaseOrderReceive.as_view(), name='purchase-order-receive'),
url(r'^export/?', views.PurchaseOrderExport.as_view(), name='purchase-order-export'),

View File

@ -165,6 +165,34 @@ class PurchaseOrderExport(AjaxView):
return DownloadFile(filedata, filename)
class PurchaseOrderReceive(AjaxView):
""" View for receiving parts which are outstanding against a PurchaseOrder.
Any parts which are outstanding are listed.
If all parts are marked as received, the order is closed out.
"""
ajax_form_title = "Receive Parts"
ajax_template_name = "order/receive_parts.html"
def get_context_data(self):
ctx = {
'order': self.order,
}
return ctx
def get(self, request, *args, **kwargs):
self.request = request
self.order = get_object_or_404(PurchaseOrder, pk=self.kwargs['pk'])
return self.renderJsonResponse(request)
class OrderParts(AjaxView):
""" View for adding various SupplierPart items to a Purchase Order.