diff options
| -rw-r--r-- | archaeological_warehouse/forms.py | 5 | 
1 files changed, 3 insertions, 2 deletions
| diff --git a/archaeological_warehouse/forms.py b/archaeological_warehouse/forms.py index 5fcc105cd..42b8e1749 100644 --- a/archaeological_warehouse/forms.py +++ b/archaeological_warehouse/forms.py @@ -333,7 +333,8 @@ class ContainerForm(CustomForm, ManageOldType, forms.Form):          dct['container_type'] = models.ContainerType.objects.get(              pk=dct['container_type'])          dct['location'] = models.Warehouse.objects.get(pk=dct['location']) -        dct['parent'] = models.Container.objects.get(pk=dct['parent']) +        if dct.get("parent", None): +            dct['parent'] = models.Container.objects.get(pk=dct['parent'])          new_item = models.Container(**dct)          new_item.save()          return new_item @@ -603,7 +604,7 @@ class QAContainerFormMulti(QAForm):      def __init__(self, *args, **kwargs):          self.items = kwargs["items"]          super(QAContainerFormMulti, self).__init__(*args, **kwargs) -        locations = set([item.location_id for item in self.items]) +        locations = {item.location_id for item in self.items}          if len(locations) == 1 and "qalocation" in self.fields:              self.fields["qalocation"].initial = locations.pop() | 
