asset/onlinesource: add fixed url,

pre defned online sources: add FAZ.net
This commit is contained in:
Frederik Jaeckel 2023-04-21 16:55:51 +02:00
parent edfa0424e5
commit 82f9d3a792
8 changed files with 120 additions and 13 deletions

View file

@ -8,6 +8,7 @@ from trytond.transaction import Transaction
from trytond.pool import Pool
from trytond.pyson import Eval, Bool, If, Date
from trytond.report import Report
from trytond.exceptions import UserError
from decimal import Decimal
from datetime import time
@ -84,8 +85,19 @@ class Asset(SymbolMixin, ModelSQL, ModelView):
help='Select sources for the course update. The course sources are tried until a valid value has been read.',
relation_name='investment.asset_source_rel',
origin='asset', target='source')
updtdays = fields.Selection(string='Select days', required=True,
selection=sel_updtdays)
updturl = fields.Char(
string='URL',
help='URL for data retrieval.',
states={
'invisible': Eval('updturl_enable', False) == False,
'required': Eval('updturl_enable', False) == True,
}, depends=['updturl_enable'])
updturl_enable = fields.Function(fields.Boolean(
string='URL required', readonly=True,
states={'invisible': True}),
'on_change_with_updturl_enable')
updtdays = fields.Selection(
string='Select days', required=True, selection=sel_updtdays)
updttime = fields.Time(string='Time',
states={
'readonly': ~Bool(Eval('updtsources')),
@ -206,6 +218,16 @@ class Asset(SymbolMixin, ModelSQL, ModelView):
"""
return 'work'
@fields.depends('updtsources')
def on_change_with_updturl_enable(self, name=None):
""" return True if a source has fixed-url
"""
if self.updtsources:
for usource in self.updtsources:
if usource.fixed_url == True:
return True
return False
@fields.depends('updtsources', 'updttime')
def on_change_updtsources(self):
""" clear time-fields