diff options
| -rw-r--r-- | archaeological_context_records/forms.py | 19 | 
1 files changed, 9 insertions, 10 deletions
| diff --git a/archaeological_context_records/forms.py b/archaeological_context_records/forms.py index 8993675e6..9b2ae129c 100644 --- a/archaeological_context_records/forms.py +++ b/archaeological_context_records/forms.py @@ -753,16 +753,16 @@ class QAContextRecordFormMulti(QAForm):      def __init__(self, *args, **kwargs):          super(QAContextRecordFormMulti, self).__init__(*args, **kwargs)          self.items = kwargs.pop("items") -        op_pk = 0          disable = False -        for cr in self.items: -            if op_pk != cr.operation.pk and op_pk > 0: -                disable = self.fields["qa_parcel"].disabled = True -                self.fields["qa_parcel"].choices = [ -                    (1, _("Parcel can be modified only if operations are the same")) -                ] -                break -            op_pk = cr.operation.pk +        if self.items > 1: +            op_pk = self.items[0].pk +            for cr in self.items[1:]: +                if op_pk != cr.operation.pk: +                    disable = self.fields["qa_parcel"].disabled = True +                    self.fields["qa_parcel"].choices = [ +                        (1, _("Parcel can be modified only if operations are the same")) +                    ] +                    break          if not disable:              self.fields["qa_parcel"].choices += [                  (p.pk, str(p)) for p in Parcel.objects.filter( @@ -770,7 +770,6 @@ class QAContextRecordFormMulti(QAForm):                  ).all()              ] -      def clean(self):          cleaned_data = super().clean()          r_type = cleaned_data.get("qa_relation_type") | 
