From 69d4f6da8ea14cf3f2524e52d5195f7294050f53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20E=2E=20G=C3=B3mez?= Date: Thu, 9 Mar 2023 02:09:42 -0500 Subject: [PATCH] [NEW] Patches Core to allow attachment access to other models --- apply_patches.sh | 11 +++++++---- ...chment_allow-portal-users-attachment-access.patch} | 5 +++-- 2 files changed, 10 insertions(+), 6 deletions(-) rename patches/{20230206_ir-attachment_allow-portal-users-attachment-access.patch => 20230309_ir-attachment_allow-portal-users-attachment-access.patch} (83%) diff --git a/apply_patches.sh b/apply_patches.sh index fa404d7..f147e88 100755 --- a/apply_patches.sh +++ b/apply_patches.sh @@ -30,12 +30,15 @@ pt_core () SRC=$PWD DEST=$DESTDIR/core/ - OPTIONS="-p1 --verbose" + OPTIONS="-p1 --verbose -R" pushd $DEST - git apply $OPTIONS $SRC/patches/20210603_auth-oauth_redirects-to-root.patch - git apply $OPTIONS $SRC/patches/20220131_purchase-requisition_match-variant.patch - git apply $OPTIONS $SRC/patches/20230206_ir-attachment_allow-portal-users-attachment-access.patch + # Already applied: + #git apply $OPTIONS $SRC/patches/20210603_auth-oauth_redirects-to-root.patch + #git apply $OPTIONS $SRC/patches/20220131_purchase-requisition_match-variant.patch + git apply $OPTIONS $SRC/patches/20230309_ir-attachment_allow-portal-users-attachment-access.patch + # Included in 2023-03-09 patch: + #git apply $OPTIONS $SRC/patches/20230206_ir-attachment_allow-portal-users-attachment-access.patch # Reverted in https://github.com/odoo/odoo/commit/8d1d62a8c0746abb30f97290304b761f74111a89: #git apply $OPTIONS $SRC/patches/20220204_mail_re-enables-buttons-in-notifications.patch popd diff --git a/patches/20230206_ir-attachment_allow-portal-users-attachment-access.patch b/patches/20230309_ir-attachment_allow-portal-users-attachment-access.patch similarity index 83% rename from patches/20230206_ir-attachment_allow-portal-users-attachment-access.patch rename to patches/20230309_ir-attachment_allow-portal-users-attachment-access.patch index 9809e6f..5d645f4 100644 --- a/patches/20230206_ir-attachment_allow-portal-users-attachment-access.patch +++ b/patches/20230309_ir-attachment_allow-portal-users-attachment-access.patch @@ -2,12 +2,13 @@ diff --git a/odoo/addons/base/models/ir_attachment.py b/odoo/addons/base/models/ index f1d8701a1..0f7926756 100644 --- a/odoo/addons/base/models/ir_attachment.py +++ b/odoo/addons/base/models/ir_attachment.py -@@ -417,7 +417,10 @@ class IrAttachment(models.Model): +@@ -418,7 +418,10 @@ class IrAttachment(models.Model): return True # Always require an internal user (aka, employee) to access to a attachment if not (self.env.is_admin() or self.env.user.has_group('base.group_user')): - raise AccessError(_("Sorry, you are not allowed to access this document.")) -+ res_models = ['account.move', 'stock.picking'] ++ res_models = ['account.move', 'stock.picking', ++ 'stock.certificate', 'stock.delivery'] + if not self.res_model or not self.res_id or self.res_model not in res_models: + raise AccessError(_("Sorry, you are not allowed to access this document.")) + self.env[self.res_model].browse(self.res_id).check_access_rule('read')