asset: bereichsgrenzen für currency_digits, farbe rot für tagesnegativ

This commit is contained in:
Frederik Jaeckel 2022-12-05 21:02:17 +01:00
parent 69afec62b0
commit 9061039ec2
2 changed files with 21 additions and 2 deletions

View file

@ -60,7 +60,10 @@ class Asset(SymbolMixin, ModelSQL, ModelView):
currency = fields.Many2One(string='Currency', select=True,
required=True, model_name='currency.currency', ondelete='RESTRICT')
currency_digits = fields.Integer(string='Digits', required=True)
currency_digits = fields.Integer(string='Digits', required=True,
domain=[
('currency_digits', '>=', 0),
('currency_digits', '<=', 8)])
wkn = fields.Function(fields.Char(string='NSIN', readonly=True,
help='National Securities Identifying Number'),
@ -155,7 +158,7 @@ class Asset(SymbolMixin, ModelSQL, ModelView):
return super().view_attributes() + [
('/tree', 'visual',
If(Eval('date', Date()) < Date(delta_days=-5), 'muted',
If(Eval('change_day1', 0) < 0, 'warning',
If(Eval('change_day1', 0) < 0, 'danger',
If(Eval('change_day1', 0) > 0, 'success', '')
))
),

View file

@ -7,6 +7,7 @@ from trytond.tests.test_tryton import ModuleTestCase, with_transaction
from trytond.pool import Pool
from trytond.modules.company.tests import create_company
from trytond.transaction import Transaction
from trytond.exceptions import UserError
from decimal import Decimal
from datetime import time, date, datetime
@ -75,6 +76,8 @@ class AssetTestCase(ModuleTestCase):
def test_asset_create(self):
""" create asset
"""
Asset = Pool().get('investment.asset')
company = self.prep_asset_company()
product = self.prep_asset_product(
name='Product 1',
@ -85,6 +88,19 @@ class AssetTestCase(ModuleTestCase):
product = product)
self.assertEqual(asset.symbol, 'usd/u')
# check ranges
Asset.write(*[
[asset],
{
'currency_digits': 1,
}])
self.assertRaisesRegex(UserError,
'ss',
Asset.write,
*[[asset], {
'currency_digits': -1,
}])
@with_transaction()
def test_asset_rec_name(self):
""" create asset