summaryrefslogtreecommitdiff
path: root/archaeological_warehouse/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_warehouse/models.py')
-rw-r--r--archaeological_warehouse/models.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py
index 7f7fbeb91..038910d17 100644
--- a/archaeological_warehouse/models.py
+++ b/archaeological_warehouse/models.py
@@ -123,7 +123,7 @@ class ContainerType(GeneralType):
length = models.IntegerField(_(u"Length (mm)"), blank=True, null=True)
width = models.IntegerField(_(u"Width (mm)"), blank=True, null=True)
height = models.IntegerField(_(u"Height (mm)"), blank=True, null=True)
- volume = models.IntegerField(_(u"Volume (l)"), blank=True, null=True)
+ volume = models.FloatField(_(u"Volume (l)"), blank=True, null=True)
reference = models.CharField(_(u"Ref."), max_length=30)
class Meta:
@@ -211,6 +211,15 @@ class Container(LightHistorizedItem):
]
return u" | ".join(locas)
+ def pre_save(self):
+ if not self.index:
+ q = Container.objects.filter(responsible=self.responsible).order_by(
+ '-index')
+ if q.count():
+ self.index = q.all()[0].index + 1
+ else:
+ self.index = 1
+
def save(self, *args, **kwargs):
super(Container, self).save(*args, **kwargs)