diff --git a/InvenTree/order/models.py b/InvenTree/order/models.py index 184452f24e..23d07a0c2e 100644 --- a/InvenTree/order/models.py +++ b/InvenTree/order/models.py @@ -257,7 +257,11 @@ class PurchaseOrder(Order): self.save() def can_cancel(self): - return self.status not in [ + """ + A PurchaseOrder can only be cancelled under the following circumstances: + """ + + return self.status in [ PurchaseOrderStatus.PLACED, PurchaseOrderStatus.PENDING ] diff --git a/InvenTree/order/templates/order/order_base.html b/InvenTree/order/templates/order/order_base.html index d3e1e02437..fa45bbfe41 100644 --- a/InvenTree/order/templates/order/order_base.html +++ b/InvenTree/order/templates/order/order_base.html @@ -47,7 +47,7 @@ src="{% static 'img/blank_image.png' %}" {% endif %} - {% if order.status == PurchaseOrderStatus.PENDING or order.status == PurchaseOrderStatus.PLACED %} + {% if order.can_cancel %} diff --git a/InvenTree/order/views.py b/InvenTree/order/views.py index bd758e39fb..091b11e825 100644 --- a/InvenTree/order/views.py +++ b/InvenTree/order/views.py @@ -432,7 +432,7 @@ class PurchaseOrderCancel(AjaxUpdateView): form.add_error('confirm', _('Confirm order cancellation')) if not order.can_cancel(): - form.add_error(None, _('Order cannot be cancelled as either pending or placed')) + form.add_error(None, _('Order cannot be cancelled')) def save(self, order, form, **kwargs): """