diff --git a/asset.py b/asset.py
index 2e32d3f..e0c493e 100644
--- a/asset.py
+++ b/asset.py
@@ -114,6 +114,9 @@ class Asset(SymbolMixin, ModelSQL, ModelView):
help='percentage change in value during 1 year',
readonly=True, digits=(16,digits_percent)),
'get_percentage_change', searcher='search_percentage')
+ change_symbol = fields.Function(fields.Many2One(string='Symbol',
+ readonly=True, model_name='investment.rate'),
+ 'get_percentage_change')
@classmethod
def __register__(cls, module_name):
@@ -564,10 +567,12 @@ class Asset(SymbolMixin, ModelSQL, ModelView):
"""
cursor = Transaction().connection.cursor()
- name_lst = [x[len('change_'):] for x in names]
+ name_lst = [x[len('change_'):] for x in names
+ if x != 'change_symbol']
tab_percent = cls.get_percentage_sql(name_lst)
query = tab_percent.select(
tab_percent.id,
+ tab_percent.id_rate,
*[getattr(tab_percent, x) for x in name_lst],
where=tab_percent.id.in_([x.id for x in assets]),
)
@@ -577,7 +582,10 @@ class Asset(SymbolMixin, ModelSQL, ModelView):
result = {x:{y.id: None for y in assets} for x in names}
exp = Decimal(Decimal(1) / 10 ** digits_percent)
for record in records:
- cnt1 = 1
+ if 'change_symbol' in names:
+ result['change_symbol'][record[0]] = record[1]
+
+ cnt1 = 2
for x in name_lst:
result['change_%s' % x][record[0]] = record[cnt1].quantize(exp) \
if record[cnt1] is not None else None
diff --git a/locale/de.po b/locale/de.po
index 1de7cbe..fef6097 100644
--- a/locale/de.po
+++ b/locale/de.po
@@ -310,6 +310,10 @@ msgctxt "help:investment.asset,change_month12:"
msgid "percentage change in value during 1 year"
msgstr "Prozentuale Wertänderung während 1 Jahr"
+msgctxt "field:investment.asset,change_symbol:"
+msgid "Symbol"
+msgstr "Symbol"
+
msgctxt "field:investment.asset,updtdays:"
msgid "Select days"
msgstr "Tage wählen"
diff --git a/locale/en.po b/locale/en.po
index 7e3c6f3..e11dbea 100644
--- a/locale/en.po
+++ b/locale/en.po
@@ -270,6 +270,10 @@ msgctxt "help:investment.asset,change_month12:"
msgid "percentage change in value during 1 year"
msgstr "percentage change in value during 1 year"
+msgctxt "field:investment.asset,change_symbol:"
+msgid "Symbol"
+msgstr "Symbol"
+
msgctxt "field:investment.asset,updtdays:"
msgid "Select days"
msgstr "Select days"
diff --git a/rate.py b/rate.py
index f37194b..dceed09 100644
--- a/rate.py
+++ b/rate.py
@@ -3,13 +3,13 @@
# The COPYRIGHT file at the top level of this repository contains the
# full copyright notices and license terms.
-from trytond.model import ModelView, ModelSQL, fields, Unique, Check
+from trytond.model import ModelView, ModelSQL, fields, Unique, Check, SymbolMixin
from trytond.transaction import Transaction
from trytond.pool import Pool
from trytond.pyson import Eval, Bool
-class Rate(ModelSQL, ModelView):
+class Rate(SymbolMixin, ModelSQL, ModelView):
'Rate'
__name__ = 'investment.rate'
@@ -29,6 +29,8 @@ class Rate(ModelSQL, ModelView):
uom = fields.Function(fields.Many2One(string='Uom',
readonly=True, model_name='product.uom'),
'on_change_with_uom')
+ symbol = fields.Function(fields.Char(string='Symbol',
+ readonly=True), 'on_change_with_symbol')
@classmethod
def __setup__(cls):
@@ -51,6 +53,11 @@ class Rate(ModelSQL, ModelView):
IrDate = Pool().get('ir.date')
return IrDate.today()
+ def on_change_with_symbol(self, name=None):
+ """ symbol:%
+ """
+ return '%'
+
@fields.depends('asset', '_parent_asset.uom')
def on_change_with_uom(self, name=None):
""" get unit of asset
diff --git a/tests/test_rate.py b/tests/test_rate.py
index 548b952..348bf07 100644
--- a/tests/test_rate.py
+++ b/tests/test_rate.py
@@ -46,5 +46,7 @@ class RateTestCase(ModuleTestCase):
self.assertEqual(asset.rates[0].uom.rec_name, 'Unit')
self.assertEqual(asset.rates[0].asset_digits, 4)
self.assertEqual(asset.rates[0].currency.rec_name, 'usd')
+ self.assertEqual(asset.rates[0].symbol, '%')
+ self.assertEqual(asset.change_symbol.symbol, '%')
# end RateTestCase
diff --git a/view/asset_form.xml b/view/asset_form.xml
index 68734e1..5233998 100644
--- a/view/asset_form.xml
+++ b/view/asset_form.xml
@@ -6,7 +6,7 @@ full copyright notices and license terms. -->
-
+
@@ -16,34 +16,16 @@ full copyright notices and license terms. -->
-
-
-
-
-
-
+
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
+
+
+
-
-
-
-
+
diff --git a/view/asset_list.xml b/view/asset_list.xml
index 67abbdb..daee4c5 100644
--- a/view/asset_list.xml
+++ b/view/asset_list.xml
@@ -4,10 +4,10 @@ The COPYRIGHT file at the top level of this repository contains the
full copyright notices and license terms. -->
-
-
-
-
+
+
+
+