From 1e1846d501973c1ad967ee158dda9ab56ea6efa5 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Sun, 12 Jun 2016 18:06:07 +0200 Subject: [PATCH] Order payments by date in refunds form --- refunding/forms.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/refunding/forms.py b/refunding/forms.py index 9c1df8d..f82852a 100644 --- a/refunding/forms.py +++ b/refunding/forms.py @@ -15,7 +15,10 @@ class RefundForm(forms.ModelForm): super(RefundForm, self).__init__(*args, **kwargs) if self.instance: self.fields['payments'].initial = self.instance.payment_set.all() - self.fields['payments'].queryset = Payment.objects.filter(Q(refund=None) | Q(refund=self.instance)) + self.fields['payments'].queryset = Payment\ + .objects\ + .filter(Q(refund=None) | Q(refund=self.instance))\ + .order_by('-date') def save(self, *args, **kwargs): # Save the refund