Add symbol widget

issue9059
review276871002
This commit is contained in:
Cédric Krier committed 2020-10-09 19:09:05 +02:00
1 parent 7f1781dec5
commit 90856c96f0
1 file changed
+12 -2
+12 -2
View File
@@ -9,7 +9,7 @@ from sql.functions import NthValue
from trytond.i18n import gettext
from trytond.model import (
ModelView, ModelSQL, DeactivableMixin, fields, Unique, Check)
ModelView, ModelSQL, DeactivableMixin, fields, Unique, Check, SymbolMixin)
from trytond.transaction import Transaction
from trytond.pool import Pool
from trytond.rpc import RPC
@@ -18,7 +18,7 @@ from trytond.pyson import Eval
from .exceptions import RateError
class Currency(DeactivableMixin, ModelSQL, ModelView):
class Currency(SymbolMixin, DeactivableMixin, ModelSQL, ModelView):
'Currency'
__name__ = 'currency.currency'
name = fields.Char('Name', required=True, translate=True,
@@ -224,6 +224,16 @@ class Currency(DeactivableMixin, ModelSQL, ModelView):
))
return query
def get_symbol(self, sign, symbol=None):
pool = Pool()
Lang = pool.get('ir.lang')
lang = Lang.get()
symbol, position = super().get_symbol(sign, symbol=symbol)
if ((sign < 0 and lang.n_cs_precedes)
or (sign >= 0 and lang.p_cs_precedes)):
position = 0
return symbol, position
class CurrencyRate(ModelSQL, ModelView):
"Currency Rate"