diff options
| -rw-r--r-- | archaeological_warehouse/forms.py | 5 | ||||
| -rw-r--r-- | archaeological_warehouse/models.py | 3 | 
2 files changed, 7 insertions, 1 deletions
| diff --git a/archaeological_warehouse/forms.py b/archaeological_warehouse/forms.py index 170edce1f..12e9f4949 100644 --- a/archaeological_warehouse/forms.py +++ b/archaeological_warehouse/forms.py @@ -308,6 +308,7 @@ class ContainerForm(CustomForm, ManageOldType, forms.Form):              raise forms.ValidationError(                  _("The parent container is not attached to the same "                    "warehouse.")) +        return self.cleaned_data["parent"]      def clean(self):          cleaned_data = self.cleaned_data @@ -343,10 +344,14 @@ class ContainerModifyForm(ContainerForm):          super(ContainerModifyForm, self).__init__(*args, **kwargs)          fields = OrderedDict()          idx = self.fields.pop('index') +        reordered = False          for key, value in self.fields.items():              fields[key] = value              if key == 'container_type':                  fields['index'] = idx +                reordered = True +        if not reordered: +            fields['index'] = idx          self.fields = fields      def clean(self): diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py index d30a90f56..096ff0b6c 100644 --- a/archaeological_warehouse/models.py +++ b/archaeological_warehouse/models.py @@ -853,7 +853,8 @@ class Container(DocumentItem, Merge, LightHistorizedItem, QRCodeItem, GeoItem,      @classmethod      def _change_child_location(cls, parent): -        for child in cls.objects.filter(parent=parent).all(): +        for child in cls.objects.filter( +                parent=parent).exclude(location=parent.location).all():              if child.location != parent.location:                  child.location = parent.location                  child.save() | 
