Merge pull request #1229 from SchrodingersGat/cancel-order-fix

Bug fix for cancelling purchase orders
This commit is contained in:
Oliver 2021-01-14 15:03:36 +11:00 committed by GitHub
commit 8d6b4a2fd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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):
"""