|
@@ -27,6 +27,7 @@ class Document(models.Model):
|
|
class AbstractItem(models.Model):
|
|
class AbstractItem(models.Model):
|
|
name = models.CharField(max_length=130)
|
|
name = models.CharField(max_length=130)
|
|
description = models.TextField(blank=True)
|
|
description = models.TextField(blank=True)
|
|
|
|
+ document = models.ForeignKey(Document)
|
|
|
|
|
|
def __str__(self):
|
|
def __str__(self):
|
|
return self.name
|
|
return self.name
|
|
@@ -57,16 +58,7 @@ class AbstractItem(models.Model):
|
|
abstract = True
|
|
abstract = True
|
|
|
|
|
|
|
|
|
|
-class AbstractCostingItem(AbstractItem):
|
|
|
|
- """ A costing item, linked to a document
|
|
|
|
- """
|
|
|
|
- document = models.ForeignKey(Document)
|
|
|
|
-
|
|
|
|
- class Meta:
|
|
|
|
- abstract = True
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-class Cost(AbstractCostingItem):
|
|
|
|
|
|
+class Cost(AbstractItem):
|
|
""" A monthtly cost we have to pay
|
|
""" A monthtly cost we have to pay
|
|
"""
|
|
"""
|
|
price = models.FloatField(help_text="Coût mensuel")
|
|
price = models.FloatField(help_text="Coût mensuel")
|
|
@@ -78,7 +70,7 @@ class Cost(AbstractCostingItem):
|
|
verbose_name = 'Coût'
|
|
verbose_name = 'Coût'
|
|
|
|
|
|
|
|
|
|
-class Good(AbstractCostingItem):
|
|
|
|
|
|
+class Good(AbstractItem):
|
|
""" A good, which replacement is provisioned
|
|
""" A good, which replacement is provisioned
|
|
"""
|
|
"""
|
|
price = models.FloatField()
|
|
price = models.FloatField()
|
|
@@ -177,11 +169,3 @@ class Service(AbstractItem):
|
|
|
|
|
|
def get_absolute_url(self):
|
|
def get_absolute_url(self):
|
|
return reverse('detail-service', kwargs={'pk': self.pk})
|
|
return reverse('detail-service', kwargs={'pk': self.pk})
|
|
-
|
|
|
|
- def document(self):
|
|
|
|
- if self.costs.exists():
|
|
|
|
- return self.costs.first().document
|
|
|
|
- elif self.goods.exists():
|
|
|
|
- return self.costs.first().document
|
|
|
|
- else:
|
|
|
|
- return None
|
|
|