[IMP] base_report_to_printer: exceptions notifications

Better handling of exceptions feedback. A notification will show up with
the issued printer and report and a button for the user to download the
report as a fallback to the failure.

TT51628
This commit is contained in:
David
2024-11-11 13:31:15 +01:00
parent c99e28f7fa
commit 90213f2a48
7 changed files with 155 additions and 85 deletions

View File

@@ -59,6 +59,8 @@ class IrActionsReport(models.Model):
"skip_printer_exception"
):
serializable_result["printer_exception"] = True
if self.env.context.get("force_print_to_client"):
serializable_result["action"] = "client"
return serializable_result
def _get_user_default_print_behaviour(self):
@@ -135,7 +137,10 @@ class IrActionsReport(models.Model):
return True
else:
return self.print_document(record_ids, data=data)
try:
return self.print_document(record_ids, data=data)
except Exception:
return
def print_document_threaded(self, report_id, record_ids, data):
with registry(self._cr.dbname).cursor() as cr:
@@ -171,6 +176,7 @@ class IrActionsReport(models.Model):
else:
title = self.report_name
behaviour["title"] = title
behaviour["res_ids"] = record_ids
# TODO should we use doc_format instead of report_type
return printer.print_document(
self, document, doc_format=self.report_type, **behaviour