From b8a25654447e5d97f33213765123818823f77f9b Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Fri, 19 Nov 2021 10:54:36 +0000 Subject: [PATCH] [FIX] project: don't check access if in sudo Before this commit, since the code make a sudo -> unsudo to check the rights, whatever the previous env, it is no more possible to create a task from an alias. This commit check that we are not already in sudo before, or in this case it doesn't check the access right with an unsudo. closes odoo/odoo#80131 X-original-commit: 56c625079ac5e4da9c7d9994b4459aa06cbfe727 Signed-off-by: Laurent Stukkens (ltu) --- addons/project/models/project.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/project/models/project.py b/addons/project/models/project.py index 2ae3b8651aa..e1c4eb52cdc 100644 --- a/addons/project/models/project.py +++ b/addons/project/models/project.py @@ -1641,6 +1641,7 @@ class Task(models.Model): # The sudo is required for a portal user as the record creation # requires the read access on other models, as mail.template # in order to compute the field tracking + was_in_sudo = self.env.su if is_portal_user: ctx = { key: value for key, value in self.env.context.items() @@ -1652,7 +1653,9 @@ class Task(models.Model): tasks = super(Task, self.with_context(mail_create_nosubscribe=True)).create(vals_list) tasks._populate_missing_personal_stages() self._task_message_auto_subscribe_notify({task: task.user_ids - self.env.user for task in tasks}) - if is_portal_user: + + # in case we were already in sudo, we don't check the rights. + if is_portal_user and not was_in_sudo: # since we use sudo to create tasks, we need to check # if the portal user could really create the tasks based on the ir rule. tasks.with_user(self.env.user).check_access_rule('create')