From 96e4f84d94480362ebbf3841951852f09c7080fc Mon Sep 17 00:00:00 2001
From: Yannick Tivisse <yti@odoo.com>
Date: Mon, 29 Nov 2021 10:31:04 +0000
Subject: [PATCH] [FIX] web: Fix access right issues on external layout prining

Backport of 3891ab34740a8 to 14.0 following f2c1ee5a622
It was not possible to print payslip report

Purpose
=======

If the user doesn't have access to ir.ui.view (aka no admin or
website access rights), printing a report with a configured
external layout will lead to a traceback, as it's forbidden
for the use to read on the field "key" on the related ir.ui.view.

As we only want to retrieve the view key, this is safe to use
sudo at that point.

Fixes odoo/odoo#81960

closes odoo/odoo#82050

Related: odoo/enterprise#23159
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
---
 addons/web/views/report_templates.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/addons/web/views/report_templates.xml b/addons/web/views/report_templates.xml
index 573d1f1a161f..e279da4e8c39 100644
--- a/addons/web/views/report_templates.xml
+++ b/addons/web/views/report_templates.xml
@@ -533,7 +533,7 @@
             </t>
         </t>
 
-        <t t-if="company.external_report_layout_id" t-call="{{company.external_report_layout_id.key}}"><t t-raw="0"/></t>
+        <t t-if="company.external_report_layout_id" t-call="{{company.external_report_layout_id.sudo().key}}"><t t-raw="0"/></t>
         <t t-else="else" t-call="web.external_layout_standard"><t t-raw="0"/></t>
 
     </template>
-- 
GitLab