Fix a super annoying validation issue

- Was throwing opaque "too many values to unpack" error
- Simply needed the name of the field.
This commit is contained in:
Oliver 2021-08-23 21:39:00 +10:00
parent 1fb76b9987
commit 8662e6a109

View File

@ -49,7 +49,9 @@ class InvenTreeMoneySerializer(MoneyField):
if amount is not None:
amount = Decimal(amount)
except:
raise ValidationError(_("Must be a valid number"))
raise ValidationError({
self.field_name: _("Must be a valid number")
})
currency = data.get(get_currency_field_name(self.field_name), self.default_currency)