From c877c938cd5b367210bf95e1c5b6cc6146164c12 Mon Sep 17 00:00:00 2001 From: Justine Doutreloux Date: Fri, 23 Feb 2024 14:20:03 +0100 Subject: [PATCH 1/2] [FIX] cmis_report_write: add override to render again to save files in cmis folder When rendering a report, the files weren't saved in the cmis folder because the override was missing. --- cmis_report_write/models/ir_actions_report.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cmis_report_write/models/ir_actions_report.py b/cmis_report_write/models/ir_actions_report.py index 4e56d692..24ca49f2 100644 --- a/cmis_report_write/models/ir_actions_report.py +++ b/cmis_report_write/models/ir_actions_report.py @@ -129,6 +129,15 @@ def _render_qweb_pdf(self, report_ref, res_ids, data=None): self.with_context(cmis_report_keys=(report, SAVE_IN_CMIS_MARKER)), )._render_qweb_pdf(report_ref, res_ids, data=data) + @api.model + def _render(self, report_ref, res_ids, data=None): + report = self._get_report(report_ref) + with report.save_in_attachment_if_required(): + return super( + IrActionsReport, + self.with_context(cmis_report_keys=(report, SAVE_IN_CMIS_MARKER)), + )._render(report_ref, res_ids, data=data) + def retrieve_attachment(self, record): if self.attachment != SAVE_IN_CMIS_MARKER: return super().retrieve_attachment(record) From 93e258df18644f25fac07646a1c01733b73c79d9 Mon Sep 17 00:00:00 2001 From: Justine Doutreloux Date: Mon, 26 Feb 2024 17:27:45 +0100 Subject: [PATCH 2/2] [FIX] cmis_report_write: fix _get_backend. ir.model.fields are not accessible by users anymore, we need to use sudo --- cmis_field/__manifest__.py | 2 +- cmis_report_write/models/ir_actions_report.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmis_field/__manifest__.py b/cmis_field/__manifest__.py index cbbe56fc..d0e58c8b 100644 --- a/cmis_field/__manifest__.py +++ b/cmis_field/__manifest__.py @@ -17,7 +17,7 @@ ], "external_dependencies": { "python": [ - "cmislib>=0.7.0", + "cmislib", # >= 0.7.0 ] }, } diff --git a/cmis_report_write/models/ir_actions_report.py b/cmis_report_write/models/ir_actions_report.py index 24ca49f2..16ecbfdf 100644 --- a/cmis_report_write/models/ir_actions_report.py +++ b/cmis_report_write/models/ir_actions_report.py @@ -219,7 +219,7 @@ def _get_cmis_filename(self, record): def _get_backend(self, record): self.ensure_one() if self.cmis_folder_field_id: - field = record._fields[self.cmis_folder_field_id.name] + field = record._fields[self.sudo().cmis_folder_field_id.name] return field.get_backend(self.env) return self.cmis_backend_id