changeset 26b152cfcb9c in modules/currency:default
details: https://hg.tryton.org/modules/currency?cmd=changeset;node=26b152cfcb9c
description:
        Add symbol widget

        issue9059
        review276871002
diffstat:

 currency.py |  14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diffs (38 lines):

diff -r 51d8ea0d5fb2 -r 26b152cfcb9c currency.py
--- a/currency.py       Thu Jul 09 10:38:50 2020 +0100
+++ b/currency.py       Fri Oct 09 19:09:05 2020 +0200
@@ -9,7 +9,7 @@
 
 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 .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 @@
                 ))
         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"

Reply via email to