diff --git a/mail_private_no_published/__manifest__.py b/mail_private_no_published/__manifest__.py index 12689a7..3fceb82 100644 --- a/mail_private_no_published/__manifest__.py +++ b/mail_private_no_published/__manifest__.py @@ -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', diff --git a/mail_private_no_published/models/mail_message.py b/mail_private_no_published/models/mail_message.py index 57e8827..7b13fcf 100644 --- a/mail_private_no_published/models/mail_message.py +++ b/mail_private_no_published/models/mail_message.py @@ -38,6 +38,13 @@ 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 + 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