more work on creditnotes, add refunded field to order, delete tickets when order is marked as refunded

This commit is contained in:
Thomas Steen Rasmussen 2016-06-18 23:42:58 +02:00
parent 037a23fa2a
commit 996ecbc36d
2 changed files with 19 additions and 1 deletions

View file

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

View file

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