mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-30 20:55:42 +00:00 
			
		
		
		
	Override prepare_value method of RoundingDecimalFormField
- Remove trailing zeros in form field display
This commit is contained in:
		| @@ -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): | ||||
|   | ||||
		Reference in New Issue
	
	Block a user