From 91be802fee1cadfe79f677376cd037fbae10c603 Mon Sep 17 00:00:00 2001
From: Carlos Lopez
Date: Tue, 29 Oct 2024 07:01:14 -0500
Subject: [PATCH] [IMP] mail_show_follower: Add an option to exclude specific
models from the CC note.
---
mail_show_follower/README.rst | 1 +
mail_show_follower/__manifest__.py | 1 +
mail_show_follower/data/config_parameter_data.xml | 7 +++++++
mail_show_follower/models/mail_mail.py | 8 +++++++-
mail_show_follower/models/res_config_settings.py | 4 ++++
mail_show_follower/readme/CONFIGURE.rst | 1 +
mail_show_follower/static/description/index.html | 1 +
mail_show_follower/views/res_config_settings.xml | 13 +++++++++++++
8 files changed, 35 insertions(+), 1 deletion(-)
create mode 100644 mail_show_follower/data/config_parameter_data.xml
diff --git a/mail_show_follower/README.rst b/mail_show_follower/README.rst
index 39d417a5e..8821a0992 100644
--- a/mail_show_follower/README.rst
+++ b/mail_show_follower/README.rst
@@ -49,6 +49,7 @@ To configure this module, you need to:
#. Go General settings/Discuss/Show Followers on mails/Text 'Sent to' and set the initial part of the message.
#. Go General settings/Discuss/Show Followers on mails/Partner format and choose desired fields to show on CC recipients.
#. Go General settings/Discuss/Show Followers on mails/Text 'Replies' and choose desired warn message
+#. Go General settings/Discuss/Show Followers in 'Models to exclude' enter the models you want to exclude from the CC note.
Usage
=====
diff --git a/mail_show_follower/__manifest__.py b/mail_show_follower/__manifest__.py
index 96b25babd..191ea54c2 100644
--- a/mail_show_follower/__manifest__.py
+++ b/mail_show_follower/__manifest__.py
@@ -15,6 +15,7 @@
"depends": ["base", "mail"],
"maintainers": ["yajo"],
"data": [
+ "data/config_parameter_data.xml",
"views/res_config_settings.xml",
"views/res_users.xml",
],
diff --git a/mail_show_follower/data/config_parameter_data.xml b/mail_show_follower/data/config_parameter_data.xml
new file mode 100644
index 000000000..0c6531140
--- /dev/null
+++ b/mail_show_follower/data/config_parameter_data.xml
@@ -0,0 +1,7 @@
+
+
+
+ show_followers.models_to_exclude
+ blog.blog,blog.post
+
+
diff --git a/mail_show_follower/models/mail_mail.py b/mail_show_follower/models/mail_mail.py
index f8949d915..845a7c4f3 100644
--- a/mail_show_follower/models/mail_mail.py
+++ b/mail_show_follower/models/mail_mail.py
@@ -60,10 +60,16 @@ class MailMail(models.Model):
def _send(self, auto_commit=False, raise_exception=False, smtp_session=None):
group_user = self.env.ref("base.group_user")
-
+ models_to_exclude = (
+ self.env["ir.config_parameter"]
+ .sudo()
+ .get_param("show_followers.models_to_exclude", "")
+ )
for mail in self:
if not (mail.model and mail.res_id and group_user):
continue
+ if models_to_exclude and mail.model in models_to_exclude.split(","):
+ continue
# recipients from any Notification Type (i.e. email, inbox, etc.)
recipients = mail.notification_ids.res_partner_id
record = self.env[mail.model].browse(mail.res_id)
diff --git a/mail_show_follower/models/res_config_settings.py b/mail_show_follower/models/res_config_settings.py
index 43c92ed5a..8c50849a3 100644
--- a/mail_show_follower/models/res_config_settings.py
+++ b/mail_show_follower/models/res_config_settings.py
@@ -29,6 +29,10 @@ class ResConfigSettings(models.TransientModel):
readonly=True,
store=False,
)
+ show_followers_models_to_exclude = fields.Char(
+ help="Tecnichal model names separated by coma",
+ config_parameter="show_followers.models_to_exclude",
+ )
@api.onchange(
"show_followers_message_sent_to",
diff --git a/mail_show_follower/readme/CONFIGURE.rst b/mail_show_follower/readme/CONFIGURE.rst
index 5085e4713..291ccb962 100644
--- a/mail_show_follower/readme/CONFIGURE.rst
+++ b/mail_show_follower/readme/CONFIGURE.rst
@@ -5,3 +5,4 @@ To configure this module, you need to:
#. Go General settings/Discuss/Show Followers on mails/Text 'Sent to' and set the initial part of the message.
#. Go General settings/Discuss/Show Followers on mails/Partner format and choose desired fields to show on CC recipients.
#. Go General settings/Discuss/Show Followers on mails/Text 'Replies' and choose desired warn message
+#. Go General settings/Discuss/Show Followers in 'Models to exclude' enter the models you want to exclude from the CC note.
diff --git a/mail_show_follower/static/description/index.html b/mail_show_follower/static/description/index.html
index d2267856b..ef0a3e0eb 100644
--- a/mail_show_follower/static/description/index.html
+++ b/mail_show_follower/static/description/index.html
@@ -399,6 +399,7 @@ In the cc, only appear when:
Go General settings/Discuss/Show Followers on mails/Text ‘Sent to’ and set the initial part of the message.
Go General settings/Discuss/Show Followers on mails/Partner format and choose desired fields to show on CC recipients.
Go General settings/Discuss/Show Followers on mails/Text ‘Replies’ and choose desired warn message
+
Go General settings/Discuss/Show Followers in ‘Models to exclude’ enter the models you want to exclude from the CC note.