Bug fix for cancelling purchase orders

This commit is contained in:
Oliver Walters 2021-01-14 14:37:49 +11:00
parent 76c938762c
commit be41741b1e
3 changed files with 7 additions and 3 deletions

View File

@ -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
]

View File

@ -47,7 +47,7 @@ src="{% static 'img/blank_image.png' %}"
<span class='fas fa-check-circle'></span>
</button>
{% endif %}
{% if order.status == PurchaseOrderStatus.PENDING or order.status == PurchaseOrderStatus.PLACED %}
{% if order.can_cancel %}
<button type='button' class='btn btn-default' id='cancel-order' title='{% trans "Cancel order" %}'>
<span class='fas fa-times-circle icon-red'></span>
</button>

View File

@ -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):
"""