From c769dc1fd3a7f97542a912eb763bcb16527c9374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Vi=20Or?= Date: Thu, 16 Feb 2023 18:07:11 +0100 Subject: [PATCH] [IMP] report_async: Add eta when async reporting --- report_async/models/ir_report.py | 2 +- report_async/models/report_async.py | 4 +++- report_async/views/report_async.xml | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/report_async/models/ir_report.py b/report_async/models/ir_report.py index e70988bdd8..a32eac840c 100644 --- a/report_async/models/ir_report.py +++ b/report_async/models/ir_report.py @@ -21,7 +21,7 @@ def report_action(self, docids, data=None, config=True): rpt_async_id = res['context']['active_id'] report_async = self.env['report.async'].browse(rpt_async_id) if res['report_type'] in REPORT_TYPES: - report_async.with_delay().run_report( + report_async.with_delay(eta=res['context'].get('eta', False)).run_report( res['context'].get('active_ids', []), data, self.id, self._uid) return {} diff --git a/report_async/models/report_async.py b/report_async/models/report_async.py index 376acc71c2..974452a1ef 100644 --- a/report_async/models/report_async.py +++ b/report_async/models/report_async.py @@ -70,6 +70,8 @@ class ReportAsync(models.Model): help="List all files created by this report background process", ) + eta = fields.Datetime(string='Execute only after') + @api.multi def _compute_job(self): for rec in self: @@ -109,7 +111,7 @@ def run_async(self): action = self.env.ref(self.action_id.xml_id) result = action.read()[0] ctx = safe_eval(result.get('context', {})) - ctx.update({'async_process': True}) + ctx.update({'async_process': True, 'eta': self.eta}) result['context'] = ctx return result diff --git a/report_async/views/report_async.xml b/report_async/views/report_async.xml index f6d5f58f14..680477e3f7 100644 --- a/report_async/views/report_async.xml +++ b/report_async/views/report_async.xml @@ -73,6 +73,8 @@ +