diff --git a/report_async/models/ir_report.py b/report_async/models/ir_report.py index e9ca999214..7fe7832804 100644 --- a/report_async/models/ir_report.py +++ b/report_async/models/ir_report.py @@ -13,7 +13,7 @@ class Report(models.Model): def report_action(self, docids, data=None, config=True): res = super().report_action(docids, data=data, config=config) if res["context"].get("async_process", False): - rpt_async_id = res["context"]["active_id"] + rpt_async_id = res["context"]["report_async_id"] report_async = self.env["report.async"].browse(rpt_async_id) if res["report_type"] in REPORT_TYPES: report_async.with_delay().run_report( diff --git a/report_async/models/report_async.py b/report_async/models/report_async.py index 0d56cba049..4d0fe97874 100644 --- a/report_async/models/report_async.py +++ b/report_async/models/report_async.py @@ -115,7 +115,7 @@ def run_async(self): raise UserError(self.env._("Background process not allowed.")) result = self.env[self.action_id.type]._for_xml_id(self.action_id.xml_id) ctx = safe_eval(result.get("context", {})) - ctx.update({"async_process": True}) + ctx.update({"async_process": True, "report_async_id": self.id}) result["context"] = ctx return result diff --git a/report_async/tests/test_report_async.py b/report_async/tests/test_report_async.py index 5b98687123..41145b07cb 100644 --- a/report_async/tests/test_report_async.py +++ b/report_async/tests/test_report_async.py @@ -27,6 +27,7 @@ def _print_wizard(self, res): active_model=self.print_doc._name, active_id=self.print_doc.id, async_process=res["context"].get("async_process"), + report_async_id=res["context"].get("report_async_id"), ) ) as form: form.reference = f"{self.test_rec._name},{self.test_rec.id}"