Compute precision also on number without digits
The %s format type even inside locale doesn't produce a localized string. So we must determine the precision of the value to format instead of relying on the %s. issue5062 review23591002
This commit is contained in:
1 parent
599612cf2e
commit
4dc63af59f
1 file changed
+3
-2
@@ -324,9 +324,10 @@ class FloatField(Field):
|
||||
if value is not None:
|
||||
digits = self.digits(record, factor=factor)
|
||||
if digits:
|
||||
return locale.format('%.*f', (digits[1], value * factor), True)
|
||||
p = digits[1]
|
||||
else:
|
||||
return locale.format('%s', value * factor, True)
|
||||
p = -int(Decimal(str(value * factor)).as_tuple().exponent)
|
||||
return locale.format('%.*f', (p, value * factor), True)
|
||||
else:
|
||||
return ''
|
||||
|
||||
|
||||
Reference in new issue
Block a user