diff --git a/quotas/forms/wizards.py b/quotas/forms/wizards.py index 0efa9fa4a..f0b861cc4 100644 --- a/quotas/forms/wizards.py +++ b/quotas/forms/wizards.py @@ -292,6 +292,12 @@ def init_fields(self): self.fields["measurement_unit"].label_from_instance = ( lambda obj: f"{obj.code} - {obj.description}" ) + self.fields["measurement_unit_qualifier"].queryset = self.fields[ + "measurement_unit_qualifier" + ].queryset.order_by("code") + self.fields["measurement_unit_qualifier"].label_from_instance = ( + lambda obj: f"{obj.code} - {obj.description}" + ) self.fields["measurement_unit_qualifier"].help_text = ( "A measurement unit qualifier is not always required" ) @@ -559,6 +565,15 @@ def init_fields(self): if "description" in definition_data: fields["description"].initial = definition_data["description"] + self.fields["measurement_unit_qualifier"].help_text = ( + "A measurement unit qualifier is not always required" + ) + self.fields["measurement_unit_qualifier"].queryset = self.fields[ + "measurement_unit_qualifier" + ].queryset.order_by("code") + self.fields["measurement_unit_qualifier"].label_from_instance = ( + lambda obj: f"{obj.code} - {obj.description}" + ) if ( "measurement_unit_qualifier" in definition_data and definition_data["measurement_unit_qualifier"] != "None" @@ -576,9 +591,6 @@ def init_fields(self): definition_data["threshold"], ) fields["quota_critical"].initial = definition_data["quota_critical"] - self.fields["measurement_unit_qualifier"].help_text = ( - "A measurement unit qualifier is not always required" - ) def update_definition_data_in_session(self, cleaned_data): cleaned_data.update(