Fix falsy negative currency formatting selection

Closes #14860
(grafted from 5e06983974daed2cb0e372a1b3a5f2cd107df751)

--HG--
branch : 8.0
This commit is contained in:
Alen Sugimoto
2026-05-24 08:31:26 -07:00
parent 18501ae6f8
commit bf9531fb55
+6 -6
View File
@@ -4,6 +4,7 @@
import datetime
from ast import literal_eval
from decimal import Decimal
from functools import partial
from itertools import takewhile
from locale import CHAR_MAX
@@ -570,6 +571,7 @@ class Lang(DeactivableMixin, ModelSQL, ModelView):
Formats val according to the currency settings in lang.
"""
# Code from currency in locale.py
conv = partial(getattr, self)
# check for illegal values
if digits is None:
@@ -586,10 +588,8 @@ class Lang(DeactivableMixin, ModelSQL, ModelView):
if symbol:
smb = currency.symbol
precedes = (val < 0 and self.n_cs_precedes
or self.p_cs_precedes)
separated = (val < 0 and self.n_sep_by_space
or self.p_sep_by_space)
precedes = conv(val < 0 and 'n_cs_precedes' or 'p_cs_precedes')
separated = conv(val < 0 and 'n_sep_by_space' or 'p_sep_by_space')
if not smb and hasattr(currency, 'code'):
smb = currency.code
separated = True
@@ -599,8 +599,8 @@ class Lang(DeactivableMixin, ModelSQL, ModelView):
else:
s = s + (separated and ' ' or '') + smb
sign_pos = val < 0 and self.n_sign_posn or self.p_sign_posn
sign = val < 0 and self.negative_sign or self.positive_sign
sign_pos = conv(val < 0 and 'n_sign_posn' or 'p_sign_posn')
sign = conv(val < 0 and 'negative_sign' or 'positive_sign')
if sign_pos == 0:
s = '(' + s + ')'