Limit digit to positive integer when formatting float in domain parser

Closes #14557
(grafted from 319126552d56ef1dd8a03e457071df0d40d0607e)

--HG--
branch : 7.0
This commit is contained in:
Cédric Krier
2026-02-28 12:57:24 +01:00
parent ebea778a70
commit c647666536
2 changed files with 3 additions and 2 deletions
+1
View File
@@ -2205,6 +2205,7 @@
}
var factor = Number(field.factor || 1);
digit -= Math.round(Math.log10(factor));
digit = Math.max(digit, 0);
return (value * factor).toLocaleString(
Sao.i18n.BC47(Sao.i18n.getlang()), {
useGrouping: true,
+2 -2
View File
@@ -349,8 +349,8 @@ def format_value(field, value, target=None, context=None, _quote_empty=False):
cast = float
factor = cast(field.get('factor', 1))
digit -= round(math.log10(factor))
return locale.localize(
'{0:.{1}f}'.format(value * factor or 0, digit), True)
digit = max(digit, 0)
return locale.localize('{0:.{1}f}'.format(value * factor, digit), True)
def format_selection():
if isinstance(field['selection'], (tuple, list)):