2022-11-18 23:21:52 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# This file is part of the investment-module from m-ds for Tryton.
|
|
|
|
# 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', []))
|
2022-12-16 13:17:28 +00:00
|
|
|
to_run_activities = []
|
2022-11-18 23:21:52 +00:00
|
|
|
for asset in assets:
|
2022-12-16 13:17:28 +00:00
|
|
|
if OnlineSource.update_rate(asset):
|
|
|
|
to_run_activities.append(asset)
|
|
|
|
|
|
|
|
if len(to_run_activities) > 0:
|
|
|
|
Asset.after_update_actions(to_run_activities)
|
|
|
|
|
2022-11-18 23:21:52 +00:00
|
|
|
return 'end'
|
|
|
|
|
|
|
|
# UpdateSoureWizard
|
2022-12-16 13:17:28 +00:00
|
|
|
|