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

[FIX] portal, website_mail: Wrong dependance #33402

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion addons/portal/controllers/mail.py
Expand Up @@ -137,7 +137,7 @@ def portal_message_fetch(self, res_model, res_id, domain=False, limit=10, offset
raise Forbidden()
# Non-employee see only messages with not internal subtype (aka, no internal logs)
if not request.env['res.users'].has_group('base.group_user'):
domain = expression.AND([['&', '&', ('subtype_id', '!=', False), ('subtype_id.internal', '=', False), ('website_published', '=', True)], domain])
domain = expression.AND([Message._non_employee_message_domain(), domain])
Message = request.env['mail.message'].sudo()
return {
'messages': Message.search(domain, limit=limit, offset=offset).portal_message_format(),
Expand Down
4 changes: 4 additions & 0 deletions addons/portal/models/mail_message.py
Expand Up @@ -21,3 +21,7 @@ def _portal_message_format(self, fields_list):
message_tree = dict((m.id, m) for m in self.sudo())
self._message_read_dict_postprocess(message_values, message_tree)
return message_values

@api.model
def _non_employee_message_domain(self):
return ['&', ('subtype_id', '!=', False), ('subtype_id.internal', '=', False)]
5 changes: 5 additions & 0 deletions addons/website_mail/models/mail_message.py
Expand Up @@ -26,6 +26,11 @@ def default_get(self, fields_list):
description = fields.Char(compute="_compute_description", help='Message description: either the subject, or the beginning of the body')
website_published = fields.Boolean(string='Published', help="Visible on the website as a comment", copy=False)

@api.model
def _non_employee_message_domain(self):
domain = super(MailMessage, self)._non_employee_message_domain()
return expression.AND([domain, [('website_published', '=', True)]])

@api.multi
def _compute_description(self):
for message in self:
Expand Down