Fallback to code to format currency without symbol
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
* Fallback to code to format currency without symbol
|
||||
* Add sort method to order like ModelStorage.search
|
||||
* Do not alter argument values of with_transaction decorator (#12108)
|
||||
* Support SMALLINT and REAL as backend types
|
||||
|
||||
@@ -501,6 +501,9 @@ class Lang(DeactivableMixin, ModelSQL, ModelView):
|
||||
or self.p_cs_precedes)
|
||||
separated = (val < 0 and self.n_sep_by_space
|
||||
or self.p_sep_by_space)
|
||||
if not smb and hasattr(currency, 'code'):
|
||||
smb = currency.code
|
||||
separated = True
|
||||
|
||||
if precedes:
|
||||
s = smb + (separated and ' ' or '') + s
|
||||
|
||||
@@ -142,6 +142,25 @@ class IrTestCase(ModuleTestCase):
|
||||
lang.currency(value, currency, symbol, grouping, digits),
|
||||
result)
|
||||
|
||||
@with_transaction()
|
||||
def test_lang_currency_without_symbol(self):
|
||||
"Test Lang.currency without symbol"
|
||||
pool = Pool()
|
||||
Lang = pool.get('ir.lang')
|
||||
lang = Lang.get('en')
|
||||
currency = Mock()
|
||||
currency.digits = 2
|
||||
currency.symbol = None
|
||||
currency.code = 'USD'
|
||||
test_data = [
|
||||
(Decimal('10.50'), True, False, None, 'USD 10.50'),
|
||||
(Decimal('10.50'), True, False, 4, 'USD 10.5000'),
|
||||
]
|
||||
for value, symbol, grouping, digits, result in test_data:
|
||||
self.assertEqual(
|
||||
lang.currency(value, currency, symbol, grouping, digits),
|
||||
result)
|
||||
|
||||
@with_transaction()
|
||||
def test_lang_format(self):
|
||||
"Test Lang.format"
|
||||
|
||||
Reference in New Issue
Block a user