Skip to content

Commit

Permalink
[IMP] Make messages website published only when sent to customers
Browse files Browse the repository at this point in the history
  • Loading branch information
valentincastravete committed Jul 3, 2024
1 parent 5e71181 commit 604d31f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion mail_private_no_published/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
{
'name': 'Mail Private No Published',
'summary': 'All messages from the private channel will not be published.',
'author': 'Oscar Soto, SDi Soluciones Informáticas',
'author': 'Oscar Soto, Valentín Georgian Castravete, Sidoo',
'website': 'https://www.sdi.es/odoo-cloud/',
'license': 'AGPL-3',
'category': 'Portal',
Expand Down
14 changes: 12 additions & 2 deletions mail_private_no_published/models/mail_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ 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
if rec.subtype_id != self.env.ref('mail.mt_note'):
continue

partner_ids = rec.partner_ids.ids
user_ids = self.env['res.users'].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
rec.website_published = False
return res

0 comments on commit 604d31f

Please sign in to comment.