details: https://code.tryton.org/tryton/commit/ca766b66599f
branch: 7.8
user: Alen Sugimoto <[email protected]>
date: Sun May 24 08:31:26 2026 -0700
description:
Fix falsy negative currency formatting selection
Closes #14860
(grafted from 5e06983974daed2cb0e372a1b3a5f2cd107df751)
diffstat:
trytond/trytond/ir/lang.py | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diffs (43 lines):
diff -r 51015089d9c5 -r ca766b66599f trytond/trytond/ir/lang.py
--- a/trytond/trytond/ir/lang.py Tue Jun 02 19:09:53 2026 +0200
+++ b/trytond/trytond/ir/lang.py Sun May 24 08:31:26 2026 -0700
@@ -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
@@ -569,6 +570,7 @@
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:
@@ -585,10 +587,8 @@
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
@@ -598,8 +598,8 @@
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 + ')'