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.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py
index c3c159550..7f7fbeb91 100644
--- a/archaeological_warehouse/models.py
+++ b/archaeological_warehouse/models.py
@@ -158,7 +158,7 @@ class Container(LightHistorizedItem):
related_name='containers')
responsible = models.ForeignKey(
Warehouse, verbose_name=_(u"Responsible warehouse"),
- related_name='owned_containers', blank=True, null=True)
+ related_name='owned_containers')
container_type = models.ForeignKey(ContainerType,
verbose_name=_("Container type"))
reference = models.CharField(_(u"Container ref."), max_length=40)
@@ -216,7 +216,7 @@ class Container(LightHistorizedItem):
if not self.index:
self.skip_history_when_saving = True
- q = Container.objects.filter(location=self.location).order_by(
+ q = Container.objects.filter(responsible=self.responsible).order_by(
'-index')
if q.count():
self.index = q.all()[0].index + 1
@@ -224,6 +224,11 @@ class Container(LightHistorizedItem):
self.index = 1
self._cached_label_checked = False
self.save()
+ # remove old location in warehouse
+ q = ContainerLocalisation.objects.filter(container=self).exclude(
+ division__warehouse=self.location)
+ for loca in q.all():
+ loca.delete()
post_save.connect(cached_label_changed, sender=Container)