mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Override prepare_value method of RoundingDecimalFormField
- Remove trailing zeros in form field display
This commit is contained in:
parent
f07f3b99cf
commit
4c96b34c7c
@ -43,7 +43,16 @@ def round_decimal(value, places):
|
||||
class RoundingDecimalFormField(forms.DecimalField):
|
||||
def to_python(self, value):
|
||||
value = super(RoundingDecimalFormField, self).to_python(value)
|
||||
return round_decimal(value, self.decimal_places)
|
||||
value = round_decimal(value, self.decimal_places)
|
||||
return value
|
||||
|
||||
def prepare_value(self, value):
|
||||
"""
|
||||
Override the 'prepare_value' method, to remove trailing zeros when displaying.
|
||||
Why? It looks nice!
|
||||
"""
|
||||
|
||||
return value.normalize()
|
||||
|
||||
|
||||
class RoundingDecimalField(models.DecimalField):
|
||||
|
Loading…
Reference in New Issue
Block a user