Add product groups to billables and invoice items

This commit is contained in:
Kumi 2020-06-22 08:47:12 +02:00
parent 49e43ad24d
commit d9e96767d5
2 changed files with 6 additions and 3 deletions

View file

@ -1,4 +1,4 @@
from django.db.models import Model, ForeignKey, CASCADE, TextField, PositiveIntegerField, BooleanField, DateField from django.db.models import Model, ForeignKey, CASCADE, TextField, PositiveIntegerField, BooleanField, DateField, ManyToManyField
from django.utils import timezone from django.utils import timezone
from core.models.profiles import ClientProfile from core.models.profiles import ClientProfile
@ -7,6 +7,7 @@ from core.fields.base import LongCharField
from core.fields.numbers import CostField from core.fields.numbers import CostField
from core.models.local import Currency from core.models.local import Currency
from core.mixins.billable import RecurMixin from core.mixins.billable import RecurMixin
from core.models.products import ProductGroup
from polymorphic.models import PolymorphicModel from polymorphic.models import PolymorphicModel
@ -29,4 +30,4 @@ class BaseBillable(PolymorphicModel):
raise NotImplementedError(f"{type(self)} does not implement property can_invoice!") raise NotImplementedError(f"{type(self)} does not implement property can_invoice!")
class Billable(RecurMixin, BaseBillable): class Billable(RecurMixin, BaseBillable):
pass product_groups = ManyToManyField(ProductGroup)

View file

@ -1,4 +1,4 @@
from django.db.models import Model, ForeignKey, CASCADE, PositiveIntegerField, TextField, BooleanField, DateField, SET_NULL, PROTECT from django.db.models import Model, ForeignKey, CASCADE, PositiveIntegerField, TextField, BooleanField, DateField, SET_NULL, PROTECT, ManyToManyField
from core.fields.base import LongCharField from core.fields.base import LongCharField
from core.fields.numbers import CostField from core.fields.numbers import CostField
@ -6,6 +6,7 @@ from core.models.profiles import ClientProfile
from core.models.local import Currency from core.models.local import Currency
from core.models.brands import Brand from core.models.brands import Brand
from core.models.billable import BaseBillable from core.models.billable import BaseBillable
from core.models.products import ProductGroup
class Invoice(Model): class Invoice(Model):
client = ForeignKey(ClientProfile, on_delete=PROTECT) client = ForeignKey(ClientProfile, on_delete=PROTECT)
@ -21,6 +22,7 @@ class InvoiceItem(Model):
sort = PositiveIntegerField() sort = PositiveIntegerField()
name = LongCharField() name = LongCharField()
description = TextField(blank=True, null=True) description = TextField(blank=True, null=True)
product_groups = ManyToManyField(ProductGroup)
price = CostField() price = CostField()
discount = CostField() discount = CostField()
taxable = BooleanField() taxable = BooleanField()