diff --git a/mail_show_follower/README.rst b/mail_show_follower/README.rst deleted file mode 100755 index 30105bff0..000000000 --- a/mail_show_follower/README.rst +++ /dev/null @@ -1,82 +0,0 @@ -.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg - :target: http://www.gnu.org/licenses/agpl - :alt: License: AGPL-3 - -================== -Mail Show Follower -================== - -This module extends the functionality of mailing to show the document followers in head of the mails. -In the cc, only appear when: - -#. The followers only count if are contacts or external users (Inner Followers will be discriminated) -#. The number of followers are more than 1. - - -Installation -============ - -To install this module, you need to: - -#. Only install. - - -Configuration -============= - -To configure this module, you need to: - -#. Go General settings/Discuss/Show Internal Users CC and set if want to show or not internal users in cc details. -#. Go Settings/Users & Company salect any user in 'Preferences' check or not the 'Show in CC' field if this user need to appear in the cc note. - - -Usage -===== - -To use this module, you need to: - -#. Send an email from any document of odoo. - - -ROADMAP -======= - - -* ... - - -Bug Tracker -=========== - -Bugs and errors are managed in `issues of GitHub `_. -In case of problems, please check if your problem has already been -reported. If you are the first to discover it, help us solving it by indicating -a detailed description `here `_. - -Do not contact contributors directly about support or help with technical issues. - - -Credits -======= - -Authors -~~~~~~~ - -* Sygel, Odoo Community Association (OCA) - - -Contributors -~~~~~~~~~~~~ - -* Valentin Vinagre - - -Maintainer -~~~~~~~~~~ - -This module is maintained by Sygel. - - -This module is part of the `Sygel/sy-server-backend `_. - -To contribute to this module, please visit https://github.com/sygel-technology. diff --git a/mail_show_follower/__init__.py b/mail_show_follower/__init__.py index d075e8eb8..0650744f6 100755 --- a/mail_show_follower/__init__.py +++ b/mail_show_follower/__init__.py @@ -1,4 +1 @@ -# Copyright 2020 Valentin Vinagre -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). - from . import models diff --git a/mail_show_follower/__manifest__.py b/mail_show_follower/__manifest__.py index b1e3dc559..47f5008e2 100755 --- a/mail_show_follower/__manifest__.py +++ b/mail_show_follower/__manifest__.py @@ -6,7 +6,7 @@ "summary": "Show CC document followers in mails.", "version": "12.0.1.0.0", "category": "Mail", - "website": "https://www.sygel.es", + "website": "https://github.com/OCA/social", "author": "Sygel, Odoo Community Association (OCA)", "license": "AGPL-3", "application": False, diff --git a/mail_show_follower/models/__init__.py b/mail_show_follower/models/__init__.py index b1d9b290c..9b936c42d 100755 --- a/mail_show_follower/models/__init__.py +++ b/mail_show_follower/models/__init__.py @@ -1,6 +1,3 @@ -# Copyright 2020 Valentin Vinagre -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). - from . import mail_mail from . import res_company from . import res_config_settings diff --git a/mail_show_follower/models/mail_mail.py b/mail_show_follower/models/mail_mail.py index c26ff4035..b06a6fc9e 100755 --- a/mail_show_follower/models/mail_mail.py +++ b/mail_show_follower/models/mail_mail.py @@ -1,6 +1,3 @@ -# Copyright 2020 Valentin Vinagre -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). - from odoo import models, api @@ -9,7 +6,12 @@ class MailMail(models.Model): @api.multi def _send(self, auto_commit=False, raise_exception=False, smtp_session=None): - plain_text = '
CC: %s
' + plain_text = ( + '
CC: %s
' + ) group_portal = self.env.ref('base.group_portal') for mail_id in self.ids: mail = self.browse(mail_id) @@ -25,28 +27,44 @@ class MailMail(models.Model): user_partner_ids = self.env['res.users'].search([ ('active', 'in', (True, False)), ('show_in_cc', '=', False), - ]).filtered(lambda x: not group_portal in x.groups_id).mapped('partner_id').ids + ]).filtered( + lambda x: group_portal not in x.groups_id + ).mapped('partner_id').ids partners_len = len(partners_obj.filtered( - lambda x: x.id not in user_partner_ids and (not x.user_ids or group_portal in x.user_ids.groups_id) - )) + lambda x: x.id not in user_partner_ids and ( + not x.user_ids or group_portal in x.user_ids.groups_id + ))) if partners_len > 1: # get partners - partners = None cc_internal = True # else get company in object if hasattr(obj, "company_id") and obj.company_id: cc_internal = obj.company_id.show_internal_users_cc # get company in user elif mail.env and mail.env.user and mail.env.user.company_id: - cc_internal = self.env.user.company_id.show_internal_users_cc + cc_internal = self.env.user.company_id.\ + show_internal_users_cc if cc_internal: partners = partners_obj.filtered( - lambda x: x.id not in user_partner_ids and (not x.user_ids or x.user_ids.show_in_cc) + lambda x: x.id not in user_partner_ids and ( + not x.user_ids or x.user_ids.show_in_cc + ) ) else: partners = partners_obj.filtered( - lambda x: x.id not in user_partner_ids and (not x.user_ids or group_portal in x.user_ids.groups_id) + lambda x: x.id not in user_partner_ids and ( + not x.user_ids or group_portal in + x.user_ids.groups_id + ) ) + partners = partners.filtered( + lambda x: + not x.user_ids + or + # otherwise, email is not sent + x.user_ids and "email" in x.user_ids.mapped( + "notification_type") + ) # get names and emails final_cc = None mails = "" @@ -57,4 +75,7 @@ class MailMail(models.Model): # it is saved in the body_html field so that it does # not appear in the odoo log mail.body_html = final_cc + mail.body_html - return super(MailMail, self)._send(auto_commit=auto_commit, raise_exception=raise_exception, smtp_session=smtp_session) + return super(MailMail, self)._send( + auto_commit=auto_commit, raise_exception=raise_exception, + smtp_session=smtp_session + ) diff --git a/mail_show_follower/models/res_company.py b/mail_show_follower/models/res_company.py index 9192b9265..d273a8c98 100644 --- a/mail_show_follower/models/res_company.py +++ b/mail_show_follower/models/res_company.py @@ -1,6 +1,3 @@ -# Copyright 2020 Valentin Vinagre -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). - from odoo import models, fields diff --git a/mail_show_follower/models/res_config_settings.py b/mail_show_follower/models/res_config_settings.py index b084b35ce..e15b818be 100644 --- a/mail_show_follower/models/res_config_settings.py +++ b/mail_show_follower/models/res_config_settings.py @@ -1,6 +1,3 @@ -# Copyright 2020 Valentin Vinagre -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). - from odoo import fields, models diff --git a/mail_show_follower/models/res_users.py b/mail_show_follower/models/res_users.py index afbcce00a..7e30a4476 100644 --- a/mail_show_follower/models/res_users.py +++ b/mail_show_follower/models/res_users.py @@ -1,6 +1,3 @@ -# Copyright 2020 Valentin Vinagre -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). - from odoo import models, fields diff --git a/mail_show_follower/readme/CONFIGURE.rst b/mail_show_follower/readme/CONFIGURE.rst new file mode 100644 index 000000000..02a169a51 --- /dev/null +++ b/mail_show_follower/readme/CONFIGURE.rst @@ -0,0 +1,4 @@ +To configure this module, you need to: + +#. Go General settings/Discuss/Show Internal Users CC and set if want to show or not internal users in cc details. +#. Go Settings/Users & Company salect any user in 'Preferences' check or not the 'Show in CC' field if this user need to appear in the cc note. diff --git a/mail_show_follower/readme/CONTRIBUTORS.rst b/mail_show_follower/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..40630f391 --- /dev/null +++ b/mail_show_follower/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Valentin Vinagre +* Lorenzo Battistini diff --git a/mail_show_follower/readme/DESCRIPTION.rst b/mail_show_follower/readme/DESCRIPTION.rst new file mode 100644 index 000000000..19d47011d --- /dev/null +++ b/mail_show_follower/readme/DESCRIPTION.rst @@ -0,0 +1,5 @@ +This module extends the functionality of mailing to show the document followers in head of the mails. +In the cc, only appear when: + +#. The followers only count if are contacts or external users (Inner Followers will be discriminated) +#. The number of followers are more than 1. diff --git a/mail_show_follower/readme/USAGE.rst b/mail_show_follower/readme/USAGE.rst new file mode 100644 index 000000000..9c3f9bf45 --- /dev/null +++ b/mail_show_follower/readme/USAGE.rst @@ -0,0 +1,3 @@ +To use this module, you need to: + +#. Send an email from any document of odoo. diff --git a/mail_show_follower/static/description/icon.png b/mail_show_follower/static/description/icon.png deleted file mode 100644 index 207fb7ad5..000000000 Binary files a/mail_show_follower/static/description/icon.png and /dev/null differ