investment/update_wiz.py

38 lines
1.1 KiB
Python
Raw Permalink Normal View History

2022-11-18 23:21:52 +00:00
# -*- coding: utf-8 -*-
# This file is part of the investment-module from m-ds.de for Tryton.
2022-11-18 23:21:52 +00:00
# The COPYRIGHT file at the top level of this repository contains the
# full copyright notices and license terms.
from trytond.wizard import Wizard, StateTransition
from trytond.pool import Pool
from trytond.transaction import Transaction
class UpdateSoureWizard(Wizard):
'Update Source'
__name__ = 'investment.source_update'
start_state = 'runupdate'
runupdate = StateTransition()
def transition_runupdate(self):
""" update selected sources
"""
pool = Pool()
OnlineSource = pool.get('investment.source')
Asset = pool.get('investment.asset')
context = Transaction().context
assets = Asset.browse(context.get('active_ids', []))
to_run_activities = []
2022-11-18 23:21:52 +00:00
for asset in assets:
if OnlineSource.update_rate(asset):
to_run_activities.append(asset)
2024-01-21 18:37:48 +00:00
if to_run_activities:
Asset.after_update_actions(to_run_activities)
2022-11-18 23:21:52 +00:00
return 'end'
# UpdateSoureWizard