Fix RecurMixin by making it an abstract model

This commit is contained in:
Kumi 2020-06-06 13:58:36 +02:00
parent b0c1e3e14f
commit 4dc0b86378
2 changed files with 7 additions and 3 deletions

View file

@ -1,4 +1,4 @@
from django.db.models import PositiveIntegerField, DateField, IntegerChoices from django.db.models import PositiveIntegerField, DateField, IntegerChoices, Model
class ActionChoices(IntegerChoices): class ActionChoices(IntegerChoices):
WAIT = 0, "Do not invoice for now" WAIT = 0, "Do not invoice for now"
@ -13,7 +13,10 @@ class CycleChoices(IntegerChoices):
MONTHS = 2, "Months" MONTHS = 2, "Months"
YEARS = 3, "Years" YEARS = 3, "Years"
class RecurMixin: class RecurMixin(Model):
class Meta:
abstract = True
date = DateField() date = DateField()
recur_action = PositiveIntegerField(choices=ActionChoices.choices) recur_action = PositiveIntegerField(choices=ActionChoices.choices)
recur_cycle = PositiveIntegerField(choices=CycleChoices.choices) recur_cycle = PositiveIntegerField(choices=CycleChoices.choices)

View file

@ -2,6 +2,7 @@ from core.fields.numbers import CostField
from core.models.local import Currency from core.models.local import Currency
from core.models.profiles import ClientProfile from core.models.profiles import ClientProfile
from core.models.billable import BaseBillable from core.models.billable import BaseBillable
from core.mixins.billable import RecurMixin
from django.db.models import Model, TextField, CharField, ManyToManyField, ForeignKey, CASCADE, PositiveIntegerField, OneToOneField, BooleanField, SET_NULL from django.db.models import Model, TextField, CharField, ManyToManyField, ForeignKey, CASCADE, PositiveIntegerField, OneToOneField, BooleanField, SET_NULL
@ -38,5 +39,5 @@ class ServicePlan(Model):
for item in productplan.serviceplanitem_set: for item in productplan.serviceplanitem_set:
ServicePlanItem.objects.create(plan=plan, cycle=item.cycle, count=item.count, cost=item.cost) ServicePlanItem.objects.create(plan=plan, cycle=item.cycle, count=item.count, cost=item.cost)
class ServicePlanItem(BaseBillable): class ServicePlanItem(RecurMixin, BaseBillable):
plan = ForeignKey(ServicePlan, on_delete=CASCADE) plan = ForeignKey(ServicePlan, on_delete=CASCADE)