summaryrefslogtreecommitdiff
path: root/archaeological_warehouse/models.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2017-01-20 20:09:06 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2017-01-20 20:09:06 +0100
commitd26217d09080ef93fe0b36c3543a266d7a04c688 (patch)
tree99faaf3ec3a2d6da7d265995419dc6af45a69fbe /archaeological_warehouse/models.py
parent4abb5ff78620c096ab4238535c8e4b22291a2cb1 (diff)
parentac595e9aa13d27fb15e70eb1f6e2d11f928a4c4a (diff)
downloadIshtar-d26217d09080ef93fe0b36c3543a266d7a04c688.tar.bz2
Ishtar-d26217d09080ef93fe0b36c3543a266d7a04c688.zip
Merge branch 'v0.9' into wheezy
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)