diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2020-12-03 20:42:10 +0100 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-02-28 12:15:22 +0100 | 
| commit | 0fdd2d23841aba8f8c3d740e4512b8840f2cc960 (patch) | |
| tree | 6622036e312b9c928476090be61c672c989f4a01 /archaeological_warehouse/forms.py | |
| parent | e0db2b843c6207d0d777d65af880bf6b929d6442 (diff) | |
| download | Ishtar-0fdd2d23841aba8f8c3d740e4512b8840f2cc960.tar.bz2 Ishtar-0fdd2d23841aba8f8c3d740e4512b8840f2cc960.zip | |
Fix container form with missing parents
Diffstat (limited to 'archaeological_warehouse/forms.py')
| -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() | 
