Allow to cancel expired orders

This commit is contained in:
Raphael Michel
2020-02-26 11:23:38 +01:00
parent cf06712eca
commit 4a2516e303
2 changed files with 3 additions and 3 deletions

View File

@@ -426,7 +426,7 @@ class Order(LockModel, LoggedModel):
def cancel_allowed(self):
return (
self.status in (Order.STATUS_PENDING, Order.STATUS_PAID) and self.count_positions
self.status in (Order.STATUS_PENDING, Order.STATUS_PAID, Order.STATUS_EXPIRED) and self.count_positions
)
@cached_property

View File

@@ -294,8 +294,8 @@ def _cancel_order(order, user=None, send_mail: bool=True, api_token=None, device
if not order.cancel_allowed():
raise OrderError(_('You cannot cancel this order.'))
invoices = []
i = order.invoices.filter(is_cancellation=False, refered__isnull=True).last()
if i:
i = order.invoices.filter(is_cancellation=False).last()
if i and not i.refered.exists():
invoices.append(generate_cancellation(i))
for position in order.positions.all():