跳至内容
菜单
此问题已终结
2 回复
1317 查看

Hi everyone,

I'm encountering an access control issue in Odoo 15 when trying to mark a mail activity as "done." Although the activity was created by the same user who is marking it as done—and thus should have sufficient rights—the process fails with an ACL error.

Here’s what’s happening:

  • When a user marks a mail activity as done (via the action_done method), the process unexpectedly attempts to read from the res.config.settings model.
  • The log shows the following error message:

"Access Denied by ACLs for operation: read, uid: 47, model: res.config.settings

No puedes ingresar a los registros 'res.config.settings' (res.config.settings) Se permite esta operación para los grupos siguientes: - Administration/Settings Ponte en contacto con tu administrador para pedirle acceso si es necesario"

The UID in the error (47) indicates that the operation is running in the context of a non-administrative user, even though the activity creator should have permissions to complete their own activity.  

To work around the issue, I tried overriding the action_done method in a custom module. My first attempt was to elevate privileges with sudo():

However, the error still occurred because, inside the super().action_done() call, some code is reading from res.config.settings with the original user context. 

Any insights or recommendations would be greatly appreciated!

形象
丢弃
编写者 最佳答案

This worked for me, it was a different method with a initial underscore:

import logging
from odoo import models, api

_logger = logging.getLogger(__name__)

class MailActivity(models.Model):
_inherit = "mail.activity"

def _action_done(self, feedback=False, attachment_ids=None):
return super(MailActivity, self.sudo())._action_done(feedback=feedback, attachment_ids=attachment_ids)
形象
丢弃
最佳答案

Hi,
If you're encountering an access denied error when calling super().action_done() even after using sudo(), it indicates that the underlying method (or a method it calls) is still executing in the context of the original user, which does not have access to res.config.settings. Here are some strategies to address this issue:

Override the Method with Proper Context,

import logging

_logger = logging.getLogger(__name__)

class MailActivity(models.Model):
    _inherit = 'mail.activity'

    @api.model
    def action_done(self):
        _logger.info("User  %s is attempting to mark activity as done.", self.env.user.id)
        self = self.sudo()
       
        # Log before calling super
        _logger.info("Calling super().action_done() with sudo.")
        return super(MailActivity, self).action_done()

Regards,
Jishna
Accurates

形象
丢弃
相关帖文 回复 查看 活动
1
3月 25
734
1
3月 24
1798
2
1月 24
2166
1
3月 15
4585
1
8月 25
483