Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][FIX] fetchmail_thread_default, mail_activity_team, mail_gateway, mass_mailing_custom_unsubscribe,add sudo call in models without explicit access #1416

Open
wants to merge 4 commits into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions fetchmail_thread_default/models/fetchmail_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def _get_thread_models(self):
"""
models = (
self.env["ir.model.fields"]
.sudo()
.search([("name", "=", "message_partner_ids")])
.mapped("model_id")
)
Expand Down
7 changes: 6 additions & 1 deletion mail_activity_team/models/mail_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ def _get_default_team_id(self, user_id=None):
if not user_id:
user_id = self.env.uid
res_model = self.env.context.get("default_res_model")
model = self.sudo().env["ir.model"].search([("model", "=", res_model)], limit=1)
model = (
self.sudo()
.env["ir.model"]
.sudo()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why two sudo's?

.search([("model", "=", res_model)], limit=1)
)
domain = [("member_ids", "in", [user_id])]
if res_model:
domain.extend(
Expand Down
2 changes: 1 addition & 1 deletion mail_gateway/wizards/mail_message_gateway_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class MailMessageGatewayLink(models.TransientModel):

@api.model
def _selection_target_model(self):
models = self.env["ir.model"].search([("is_mail_thread", "=", True)])
models = self.env["ir.model"].sudo().search([("is_mail_thread", "=", True)])
return [(model.model, model.name) for model in models]

def link_message(self):
Expand Down
8 changes: 6 additions & 2 deletions mass_mailing_custom_unsubscribe/models/mail_unsubscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,12 @@ def _default_date(self):
@api.model
def _selection_unsubscriber_id(self):
"""Models that can be linked to a ``mailing.mailing``."""
models = self.env["ir.model"].search(
[("is_mailing_enabled", "=", True), ("model", "!=", "mailing.list")]
models = (
self.env["ir.model"]
.sudo()
.search(
[("is_mailing_enabled", "=", True), ("model", "!=", "mailing.list")]
)
)
return [(model.model, model.name) for model in models]

Expand Down
Loading