asset: bereichsgrenzen für currency_digits, farbe rot für tagesnegativ
This commit is contained in:
parent
69afec62b0
commit
9061039ec2
2 changed files with 21 additions and 2 deletions
7
asset.py
7
asset.py
|
@ -60,7 +60,10 @@ class Asset(SymbolMixin, ModelSQL, ModelView):
|
||||||
|
|
||||||
currency = fields.Many2One(string='Currency', select=True,
|
currency = fields.Many2One(string='Currency', select=True,
|
||||||
required=True, model_name='currency.currency', ondelete='RESTRICT')
|
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,
|
wkn = fields.Function(fields.Char(string='NSIN', readonly=True,
|
||||||
help='National Securities Identifying Number'),
|
help='National Securities Identifying Number'),
|
||||||
|
@ -155,7 +158,7 @@ class Asset(SymbolMixin, ModelSQL, ModelView):
|
||||||
return super().view_attributes() + [
|
return super().view_attributes() + [
|
||||||
('/tree', 'visual',
|
('/tree', 'visual',
|
||||||
If(Eval('date', Date()) < Date(delta_days=-5), 'muted',
|
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', '')
|
If(Eval('change_day1', 0) > 0, 'success', '')
|
||||||
))
|
))
|
||||||
),
|
),
|
||||||
|
|
|
@ -7,6 +7,7 @@ from trytond.tests.test_tryton import ModuleTestCase, with_transaction
|
||||||
from trytond.pool import Pool
|
from trytond.pool import Pool
|
||||||
from trytond.modules.company.tests import create_company
|
from trytond.modules.company.tests import create_company
|
||||||
from trytond.transaction import Transaction
|
from trytond.transaction import Transaction
|
||||||
|
from trytond.exceptions import UserError
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from datetime import time, date, datetime
|
from datetime import time, date, datetime
|
||||||
|
|
||||||
|
@ -75,6 +76,8 @@ class AssetTestCase(ModuleTestCase):
|
||||||
def test_asset_create(self):
|
def test_asset_create(self):
|
||||||
""" create asset
|
""" create asset
|
||||||
"""
|
"""
|
||||||
|
Asset = Pool().get('investment.asset')
|
||||||
|
|
||||||
company = self.prep_asset_company()
|
company = self.prep_asset_company()
|
||||||
product = self.prep_asset_product(
|
product = self.prep_asset_product(
|
||||||
name='Product 1',
|
name='Product 1',
|
||||||
|
@ -85,6 +88,19 @@ class AssetTestCase(ModuleTestCase):
|
||||||
product = product)
|
product = product)
|
||||||
self.assertEqual(asset.symbol, 'usd/u')
|
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()
|
@with_transaction()
|
||||||
def test_asset_rec_name(self):
|
def test_asset_rec_name(self):
|
||||||
""" create asset
|
""" create asset
|
||||||
|
|
Loading…
Reference in a new issue