more work on creditnotes, add refunded field to order, delete tickets when order is marked as refunded
This commit is contained in:
parent
037a23fa2a
commit
996ecbc36d
|
@ -54,6 +54,7 @@ class OrderAdmin(admin.ModelAdmin):
|
|||
'open',
|
||||
'paid',
|
||||
'cancelled',
|
||||
'refunded',
|
||||
]
|
||||
|
||||
list_filter = [
|
||||
|
@ -62,6 +63,7 @@ class OrderAdmin(admin.ModelAdmin):
|
|||
'open',
|
||||
'paid',
|
||||
'cancelled',
|
||||
'refunded',
|
||||
'user',
|
||||
]
|
||||
|
||||
|
@ -69,11 +71,15 @@ class OrderAdmin(admin.ModelAdmin):
|
|||
|
||||
inlines = [ProductInline, TicketInline]
|
||||
|
||||
actions = ['mark_order_as_paid']
|
||||
actions = ['mark_order_as_paid', 'mark_order_as_refunded']
|
||||
|
||||
def mark_order_as_paid(self, request, queryset):
|
||||
for order in queryset.filter(paid=False):
|
||||
order.mark_as_paid()
|
||||
mark_order_as_paid.description = 'Mark order(s) as paid'
|
||||
|
||||
def mark_order_as_refunded(self, request, queryset):
|
||||
for order in queryset.filter(refunded=False):
|
||||
order.mark_as_refunded()
|
||||
mark_order_as_refunded.description = 'Mark order(s) as refunded'
|
||||
|
||||
|
|
|
@ -74,6 +74,12 @@ class Order(CreatedUpdatedModel):
|
|||
|
||||
cancelled = models.BooleanField(default=False)
|
||||
|
||||
refunded = models.BooleanField(
|
||||
verbose_name=_('Refunded?'),
|
||||
help_text=_('Whether this order has been refunded.'),
|
||||
default=False,
|
||||
)
|
||||
|
||||
objects = OrderQuerySet.as_manager()
|
||||
|
||||
def __str__(self):
|
||||
|
@ -137,6 +143,12 @@ class Order(CreatedUpdatedModel):
|
|||
ticket.save()
|
||||
self.save()
|
||||
|
||||
def mark_as_refunded(self):
|
||||
self.refunded=True
|
||||
### delete any tickets related to this order
|
||||
self.tickets.all().delete()
|
||||
self.save()
|
||||
|
||||
def is_not_handed_out(self):
|
||||
if self.orderproductrelation_set.filter(handed_out=True).count() == 0:
|
||||
return True
|
||||
|
|
Loading…
Reference in a new issue