From fcbc0a20d4ccf34b83055661c4615a30e5ac6576 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valent=C3=ADn=20Georgian=20Castravete?= Date: Wed, 3 Jul 2024 12:14:15 +0200 Subject: [PATCH 1/2] [IMP] Make notes also non website published --- mail_private_no_published/models/mail_message.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mail_private_no_published/models/mail_message.py b/mail_private_no_published/models/mail_message.py index 7b13fcf..4739072 100644 --- a/mail_private_no_published/models/mail_message.py +++ b/mail_private_no_published/models/mail_message.py @@ -38,6 +38,10 @@ 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([ ('partner_id', 'in', partner_ids), From b330bdad4de4e15f10aec5238fb6c4e43914c6cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valent=C3=ADn=20Georgian=20Castravete?= Date: Wed, 3 Jul 2024 14:40:20 +0200 Subject: [PATCH 2/2] [FIX] Publish customer messages on website --- mail_private_no_published/models/mail_message.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mail_private_no_published/models/mail_message.py b/mail_private_no_published/models/mail_message.py index 4739072..b0651b6 100644 --- a/mail_private_no_published/models/mail_message.py +++ b/mail_private_no_published/models/mail_message.py @@ -43,12 +43,21 @@ def create(self, vals): 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