diff --git a/InvenTree/order/models.py b/InvenTree/order/models.py index 1c59a0bb31..756f185c32 100644 --- a/InvenTree/order/models.py +++ b/InvenTree/order/models.py @@ -479,6 +479,11 @@ class PurchaseOrder(TotalPriceMixin, Order): """Return True if the PurchaseOrder is 'pending'""" return self.status == PurchaseOrderStatus.PENDING + @property + def is_open(self): + """Return True if the PurchaseOrder is 'open'""" + return self.status in PurchaseOrderStatus.OPEN + def can_cancel(self): """A PurchaseOrder can only be cancelled under the following circumstances. @@ -813,9 +818,9 @@ class SalesOrder(TotalPriceMixin, Order): if self.lines.count() == 0: raise ValidationError(_('Order cannot be completed as no parts have been assigned')) - # Only a PENDING order can be marked as SHIPPED - elif self.status != SalesOrderStatus.PENDING: - raise ValidationError(_('Only a pending order can be marked as complete')) + # Only an open order can be marked as shipped + elif not self.is_open: + raise ValidationError(_('Only an open order can be marked as complete')) elif self.pending_shipment_count > 0: raise ValidationError(_("Order cannot be completed as there are incomplete shipments")) diff --git a/InvenTree/order/templates/order/order_base.html b/InvenTree/order/templates/order/order_base.html index 08da68fa42..aafe96d1c0 100644 --- a/InvenTree/order/templates/order/order_base.html +++ b/InvenTree/order/templates/order/order_base.html @@ -57,11 +57,11 @@ {% endif %} -{% if order.status == PurchaseOrderStatus.PENDING %} +{% if order.is_pending %} -{% elif order.status == PurchaseOrderStatus.PLACED %} +{% elif order.is_open %} @@ -248,7 +248,7 @@ onPanelLoad('order-items', function() { name: 'purchaseorderextraline', filtertarget: '#filter-list-purchase-order-extra-lines', {% settings_value "PURCHASEORDER_EDIT_COMPLETED_ORDERS" as allow_edit %} - {% if order.is_pending or allow_edit %} + {% if order.is_open or allow_edit %} allow_edit: {% js_bool roles.purchase_order.change %}, allow_delete: {% js_bool roles.purchase_order.delete %}, {% else %} diff --git a/InvenTree/order/templates/order/sales_order_detail.html b/InvenTree/order/templates/order/sales_order_detail.html index d484c42b41..c25b1862d7 100644 --- a/InvenTree/order/templates/order/sales_order_detail.html +++ b/InvenTree/order/templates/order/sales_order_detail.html @@ -64,7 +64,7 @@ -{% if order.is_pending %} +{% if order.is_open %}
@@ -166,7 +166,7 @@ // Callback when the "shipments" panel is first loaded onPanelLoad('order-shipments', function() { - {% if order.is_pending %} + {% if order.is_open %} loadSalesOrderShipmentTable('#pending-shipments-table', { order: {{ order.pk }}, shipped: false, diff --git a/InvenTree/order/templates/order/so_sidebar.html b/InvenTree/order/templates/order/so_sidebar.html index c43e0537c5..18a421d68f 100644 --- a/InvenTree/order/templates/order/so_sidebar.html +++ b/InvenTree/order/templates/order/so_sidebar.html @@ -4,7 +4,7 @@ {% trans "Line Items" as text %} {% include "sidebar_item.html" with label='order-items' text=text icon="fa-list-ol" %} -{% if order.is_pending %} +{% if order.is_open %} {% trans "Pending Shipments" as text %} {% include "sidebar_item.html" with label='order-shipments' text=text icon="fa-truck-loading" %} {% endif %}