From 4dc63af59f53e531271e72b21d69205f94dea16e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 22 Oct 2015 18:16:26 +0200 Subject: [PATCH] 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 --- tryton/gui/window/view_form/model/field.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tryton/gui/window/view_form/model/field.py b/tryton/gui/window/view_form/model/field.py index 3c64cabaf1..a1735013df 100644 --- a/tryton/gui/window/view_form/model/field.py +++ b/tryton/gui/window/view_form/model/field.py @@ -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 ''