2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-12-14 00:09:56 +00:00

Allow null values for InvenTreeDecimalField (#10948)

- Fixes bug related to importing null "rounding_multiple" BOM field
This commit is contained in:
Oliver
2025-12-04 07:04:07 +11:00
committed by GitHub
parent 3e35f439c0
commit 7920b0e670

View File

@@ -646,6 +646,11 @@ class InvenTreeDecimalField(serializers.FloatField):
def to_internal_value(self, data):
"""Convert to python type."""
if data in [None, '']:
if self.allow_null:
return None
raise serializers.ValidationError(_('This field may not be null.'))
# Convert the value to a string, and then a decimal
try:
return Decimal(str(data))