mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-09 08:15:27 +01:00
Enhancement: allow specifying default currency for Monetary custom field (#7381)
This commit is contained in:
parent
0ee85aae21
commit
15554322dd
13 changed files with 168 additions and 29 deletions
|
|
@ -507,6 +507,23 @@ class CustomFieldSerializer(serializers.ModelSerializer):
|
|||
raise serializers.ValidationError(
|
||||
{"error": "extra_data.select_options must be a valid list"},
|
||||
)
|
||||
elif (
|
||||
"data_type" in attrs
|
||||
and attrs["data_type"] == CustomField.FieldDataType.MONETARY
|
||||
and "extra_data" in attrs
|
||||
and "default_currency" in attrs["extra_data"]
|
||||
and attrs["extra_data"]["default_currency"] is not None
|
||||
and (
|
||||
not isinstance(attrs["extra_data"]["default_currency"], str)
|
||||
or (
|
||||
len(attrs["extra_data"]["default_currency"]) > 0
|
||||
and len(attrs["extra_data"]["default_currency"]) != 3
|
||||
)
|
||||
)
|
||||
):
|
||||
raise serializers.ValidationError(
|
||||
{"error": "extra_data.default_currency must be a 3-character string"},
|
||||
)
|
||||
return super().validate(attrs)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue