diff --git a/InvenTree/company/templates/company/detail_purchase_orders.html b/InvenTree/company/templates/company/detail_purchase_orders.html index 0b9882a041..f2f3b8ceb3 100644 --- a/InvenTree/company/templates/company/detail_purchase_orders.html +++ b/InvenTree/company/templates/company/detail_purchase_orders.html @@ -6,11 +6,32 @@

Open Purchase Orders

+
+
+ +
+
+ {% include "order/po_table.html" with orders=company.outstanding_purchase_orders.all %} {% if company.closed_purchase_orders.count > 0 %} {% include "order/po_table_collapse.html" with title="Closed Orders" orders=company.closed_purchase_orders.all %} {% endif %} +{% endblock %} + +{% block js_ready %} +{{ block.super }} + +$("#po-create").click(function() { + launchModalForm("{% url 'purchase-order-create' %}", + { + data: { + supplier: {{ company.id }}, + }, + follow: true, + } + ); +}); {% endblock %} \ No newline at end of file diff --git a/InvenTree/order/models.py b/InvenTree/order/models.py index e71e50f743..7ca2e942fd 100644 --- a/InvenTree/order/models.py +++ b/InvenTree/order/models.py @@ -7,7 +7,7 @@ Order model definitions from django.db import models from django.core.validators import MinValueValidator from django.contrib.auth.models import User - +from django.urls import reverse from django.utils.translation import ugettext as _ from datetime import datetime @@ -98,6 +98,9 @@ class PurchaseOrder(Order): help_text=_('Company') ) + def get_absolute_url(self): + return reverse('purchase-order-detail', kwargs={'pk': self.id}) + class OrderLineItem(models.Model): """ Abstract model for an order line item diff --git a/InvenTree/order/templates/order/po_table.html b/InvenTree/order/templates/order/po_table.html index 5d5295b25e..0c1149470f 100644 --- a/InvenTree/order/templates/order/po_table.html +++ b/InvenTree/order/templates/order/po_table.html @@ -7,7 +7,7 @@ {% for order in orders %} - {% include "hover_image.html" with image=order.supplier.image hover=True %}{{ order.supplier.name }} + {% include "hover_image.html" with image=order.supplier.image hover=True %}{{ order.supplier.name }} {{ order }} {{ order.description }} {% include "order/order_status.html" %} diff --git a/InvenTree/order/templates/order/purchase_order_detail.html b/InvenTree/order/templates/order/purchase_order_detail.html index 404b947bd1..b6751e044d 100644 --- a/InvenTree/order/templates/order/purchase_order_detail.html +++ b/InvenTree/order/templates/order/purchase_order_detail.html @@ -31,6 +31,10 @@ InvenTree | {{ order }}

Purchase Order Details

+ + + + @@ -57,7 +61,7 @@ InvenTree | {{ order }}
- {% if order.status == OrderStatus.PENDING %} + {% if order.status == OrderStatus.PENDING and order.lines.count > 0 %} {% endif %}
diff --git a/InvenTree/order/views.py b/InvenTree/order/views.py index 7666d007d9..951de8c6fd 100644 --- a/InvenTree/order/views.py +++ b/InvenTree/order/views.py @@ -10,7 +10,7 @@ from django.views.generic import DetailView, ListView from django.forms import HiddenInput from .models import PurchaseOrder, PurchaseOrderLineItem -from company.models import SupplierPart +from company.models import Company, SupplierPart from . import forms as order_forms @@ -70,6 +70,15 @@ class PurchaseOrderCreate(AjaxCreateView): initials['status'] = OrderStatus.PENDING + supplier_id = self.request.GET.get('supplier', None) + + if supplier_id: + try: + supplier = Company.objects.get(id=supplier_id) + initials['supplier'] = supplier + except Company.DoesNotExist: + pass + return initials
Supplier{{ order.supplier }}
Status {% include "order/order_status.html" %}