Skip to content

Commit

Permalink
Merge pull request #348 from SDIsl/12.0-fix_website_published_messages
Browse files Browse the repository at this point in the history
12.0 fix website published messages
  • Loading branch information
valentincastravete authored Jul 3, 2024
2 parents b8da03e + b330bda commit 6dc1acb
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion mail_private_no_published/models/mail_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,26 @@ def _check_archive(self):
def create(self, vals):
res = super().create(vals)
for rec in res:
if rec.subtype_id == self.env.ref('mail.mt_note'):
rec.website_published = False
continue

partner_ids = rec.partner_ids.ids
user_ids = self.env['res.users'].search([
user_ids = self.env['res.users'].sudo().search([
('partner_id', 'in', partner_ids),
('active', 'in', [True, False]),
])
customer_users = user_ids.filtered(lambda user: user.has_group('base.group_portal'))
if customer_users or (partner_ids and not user_ids):
continue

author_id = rec.author_id
user = self.env['res.users'].sudo().search([
('partner_id', '=', author_id.id),
('active', 'in', [True, False]),
])
if not user or (user and not user.has_group('base.group_user')):
continue

rec.website_published = False
return res

0 comments on commit 6dc1acb

Please sign in to comment.