changeset 8e13d64f983f in tryton:default details: https://hg.tryton.org/tryton?cmd=changeset;node=8e13d64f983f description: Execute report asynchronously
Some reports may be long to generate so it is better to display the watch cursor. issue8845 review349111003 diffstat: CHANGELOG | 1 + tryton/action/main.py | 36 ++++++++++++++++++------------------ 2 files changed, 19 insertions(+), 18 deletions(-) diffs (62 lines): diff -r 42d0c1e001a1 -r 8e13d64f983f CHANGELOG --- a/CHANGELOG Sun Jan 24 20:59:46 2021 +0100 +++ b/CHANGELOG Mon Jan 25 22:13:11 2021 +0100 @@ -1,3 +1,4 @@ +* Execute report asynchronously * Add support for Python 3.9 * Support empty value for timedelta converter * Add interactive search on tree view diff -r 42d0c1e001a1 -r 8e13d64f983f tryton/action/main.py --- a/tryton/action/main.py Sun Jan 24 20:59:46 2021 +0100 +++ b/tryton/action/main.py Mon Jan 25 22:13:11 2021 +0100 @@ -4,7 +4,7 @@ import webbrowser import tryton.rpc as rpc -from tryton.common import RPCProgress, RPCExecute, RPCException +from tryton.common import RPCExecute, RPCException from tryton.common import message, selection, file_write, file_open from tryton.config import CONFIG from tryton.pyson import PYSONDecoder @@ -18,24 +18,24 @@ def exec_report(name, data, direct_print=False, context=None): if context is None: context = {} - data = data.copy() - ctx = rpc.CONTEXT.copy() - ctx.update(context) - ctx['direct_print'] = direct_print - args = ('report', name, 'execute', data.get('ids', []), data, ctx) - try: - res = RPCProgress('execute', args).run() - except RPCException: - return False - if not res: - return False - (type, data, print_p, name) = res - if not print_p and direct_print: - print_p = True + else: + context = context.copy() + context['direct_print'] = direct_print + ids = data.get('ids', []) - fp_name = file_write((name, type), data) - file_open(fp_name, type, print_p=print_p) - return True + def callback(result): + try: + result = result() + except RPCException: + return + type, data, print_p, name = result + if not print_p and direct_print: + print_p = True + fp_name = file_write((name, type), data) + file_open(fp_name, type, print_p=print_p) + RPCExecute( + 'report', name, 'execute', ids, data, context=context, + callback=callback) @staticmethod def execute(action, data, context=None, keyword=False):