Browse Source

Do not crash if no member attached to the invoice when request for ownership

Fabs 10 years ago
parent
commit
772da31156
2 changed files with 5 additions and 2 deletions
  1. 4 2
      coin/billing/models.py
  2. 1 0
      coin/billing/utils.py

+ 4 - 2
coin/billing/models.py

@@ -94,8 +94,10 @@ class Invoice(models.Model):
     amount_remaining_to_pay.short_description = 'Reste à payer'
 
     def has_owner(self, username):
-        "Check if passed username (ex gmajax) is owner of the invoice"
-        return (self.member.username == username)
+        """
+        Check if passed username (ex gmajax) is owner of the invoice
+        """
+        return (self.member and self.member.username == username)
 
     def generate_pdf(self):
         "Make and store a pdf file for the invoice"

+ 1 - 0
coin/billing/utils.py

@@ -4,6 +4,7 @@ from __future__ import unicode_literals
 from coin.billing.models import Invoice
 from django.shortcuts import render, get_object_or_404
 
+
 def get_invoice_from_id_or_number(id):
     try:
         return Invoice.objects.get(pk=id)