From cadaf4313128c9b7d88be24ef5a8163afe0af447 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Fri, 24 Mar 2017 18:50:57 -0300 Subject: [PATCH] Remove is_checkout field from Operation model --- kfet/models.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/kfet/models.py b/kfet/models.py index 419cd0a0..e54ca0cd 100644 --- a/kfet/models.py +++ b/kfet/models.py @@ -510,12 +510,14 @@ class Operation(models.Model): DEPOSIT = 'deposit' WITHDRAW = 'withdraw' INITIAL = 'initial' + EDIT = 'edit' TYPE_ORDER_CHOICES = ( (PURCHASE, 'Achat'), (DEPOSIT, 'Charge'), (WITHDRAW, 'Retrait'), (INITIAL, 'Initial'), + (EDIT, 'Édition'), ) group = models.ForeignKey( @@ -527,7 +529,6 @@ class Operation(models.Model): amount = models.DecimalField( max_digits = 6, decimal_places = 2, blank = True, default = 0) - is_checkout = models.BooleanField(default = True) # Optional article = models.ForeignKey( Article, on_delete = models.PROTECT, @@ -549,6 +550,14 @@ class Operation(models.Model): max_digits = 6, decimal_places = 2, blank = True, null = True, default = None) + @property + def is_checkout(self): + return (self.type == DEPOSIT or + self.type == WITHDRAW or + (self.type == PURCHASE and self.group and + self.group.on_acc.is_cash) + ) + class GlobalPermissions(models.Model): class Meta: managed = False