Skip to content

Commit

Permalink
[IMP] mail_show_follower: Add an option to exclude specific models fr…
Browse files Browse the repository at this point in the history
…om the CC note.
  • Loading branch information
carlos-lopez-tecnativa committed Oct 29, 2024
1 parent f99831a commit c149bcf
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions mail_show_follower/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
=====
Expand Down
1 change: 1 addition & 0 deletions mail_show_follower/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"depends": ["base", "mail"],
"maintainers": ["yajo"],
"data": [
"data/config_parameter_data.xml",
"views/res_config_settings.xml",
"views/res_users.xml",
],
Expand Down
7 changes: 7 additions & 0 deletions mail_show_follower/data/config_parameter_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<record id="models_to_exclude_config_parameter" model="ir.config_parameter">
<field name="key">show_followers.models_to_exclude</field>
<field name="value">blog.blog,blog.post</field>
</record>
</odoo>
8 changes: 7 additions & 1 deletion mail_show_follower/models/mail_mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,16 @@ def remove_p(markup_txt):

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

Check warning on line 72 in mail_show_follower/models/mail_mail.py

View check run for this annotation

Codecov / codecov/patch

mail_show_follower/models/mail_mail.py#L72

Added line #L72 was not covered by tests
# 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)
Expand Down
4 changes: 4 additions & 0 deletions mail_show_follower/models/res_config_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions mail_show_follower/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
1 change: 1 addition & 0 deletions mail_show_follower/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ <h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<li>Go General settings/Discuss/Show Followers on mails/Text ‘Sent to’ and set the initial part of the message.</li>
<li>Go General settings/Discuss/Show Followers on mails/Partner format and choose desired fields to show on CC recipients.</li>
<li>Go General settings/Discuss/Show Followers on mails/Text ‘Replies’ and choose desired warn message</li>
<li>Go General settings/Discuss/Show Followers in ‘Models to exclude’ enter the models you want to exclude from the CC note.</li>
</ol>
</div>
<div class="section" id="usage">
Expand Down
13 changes: 13 additions & 0 deletions mail_show_follower/views/res_config_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@
style="display:inline-block;"
/>
</div>
<div>
<label
for="show_followers_models_to_exclude"
string="Models to exclude"
class="o_light_label"
style="vertical-align: top;"
/>
<field
name="show_followers_models_to_exclude"
placeholder="blog.blog,blog.post"
style="display:inline-block;"
/>
</div>
</div>
<label
for="show_followers_message_preview"
Expand Down

0 comments on commit c149bcf

Please sign in to comment.