diff --git a/mail_show_follower/README.rst b/mail_show_follower/README.rst new file mode 100644 index 0000000000..f85205e62e --- /dev/null +++ b/mail_show_follower/README.rst @@ -0,0 +1,106 @@ +================== +Mail Show Follower +================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github + :target: https://github.com/OCA/social/tree/15.0/mail_show_follower + :alt: OCA/social +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/social-15-0/social-15-0-mail_show_follower + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/205/15.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +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. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +To configure this module, you need to: + +#. Go General settings/Discuss/Show Followers on mails/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. +#. 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 + +Usage +===== + +To use this module, you need to: + +#. Send an email from any document of odoo. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Sygel +* Moduon + +Contributors +~~~~~~~~~~~~ + +* Valentin Vinagre +* Lorenzo Battistini +* Eduardo de Miguel + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +.. |maintainer-yajo| image:: https://github.com/yajo.png?size=40px + :target: https://github.com/yajo + :alt: yajo + +Current `maintainer `__: + +|maintainer-yajo| + +This module is part of the `OCA/social `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/mail_show_follower/__init__.py b/mail_show_follower/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/mail_show_follower/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/mail_show_follower/__manifest__.py b/mail_show_follower/__manifest__.py new file mode 100644 index 0000000000..3da1c9322a --- /dev/null +++ b/mail_show_follower/__manifest__.py @@ -0,0 +1,22 @@ +# Copyright 2020 Valentin Vinagre +# Copyright 2022 Eduardo de Miguel +# Copyright 2025 Thomas Pot +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Mail Show Follower", + "summary": "Show CC document followers in mails.", + "version": "18.0.1.2", + "category": "Mail", + "website": "https://github.com/OCA/social", + "author": "Sygel, Moduon, Odoo Community Association (OCA)", + "license": "AGPL-3", + "application": False, + "installable": True, + "depends": ["base", "mail"], + "maintainers": ["yajo"], + "data": [ + "views/res_config_settings.xml", + "views/res_users.xml", + ], +} diff --git a/mail_show_follower/i18n/fr.po b/mail_show_follower/i18n/fr.po new file mode 100644 index 0000000000..d25770af57 --- /dev/null +++ b/mail_show_follower/i18n/fr.po @@ -0,0 +1,111 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_show_follower +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2022-01-19 15:32+0000\n" +"Last-Translator: Yann Papouin \n" +"Language-Team: none\n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 4.3.2\n" + +#. module: mail_show_follower +#: model_terms:ir.ui.view,arch_db:mail_show_follower.res_config_settings_view_form +msgid "%(partner_name)s <%(partner_email)s>" +msgstr "" + +#. module: mail_show_follower +#: model:ir.model,name:mail_show_follower.model_res_company +msgid "Companies" +msgstr "Sociétés" + +#. module: mail_show_follower +#: model:ir.model,name:mail_show_follower.model_res_config_settings +msgid "Config Settings" +msgstr "Paramétrage" + +#. module: mail_show_follower +#: model:ir.model.fields,field_description:mail_show_follower.field_res_config_settings__show_followers_message_preview +msgid "Message preview" +msgstr "" + +#. module: mail_show_follower +#: model_terms:ir.ui.view,arch_db:mail_show_follower.res_config_settings_view_form +msgid "Notice: Replies to this email will be sent to all recipients." +msgstr "" + +#. module: mail_show_follower +#: model:ir.model,name:mail_show_follower.model_mail_mail +msgid "Outgoing Mails" +msgstr "Courriels à envoyer" + +#. module: mail_show_follower +#: model:ir.model.fields,field_description:mail_show_follower.field_res_company__show_followers_partner_format +#: model:ir.model.fields,field_description:mail_show_follower.field_res_config_settings__show_followers_partner_format +msgid "Partner format" +msgstr "" + +#. module: mail_show_follower +#: model_terms:ir.ui.view,arch_db:mail_show_follower.res_config_settings_view_form +msgid "Show Followers on mails" +msgstr "" + +#. module: mail_show_follower +#: model:ir.model.fields,field_description:mail_show_follower.field_res_company__show_internal_users_cc +#: model:ir.model.fields,field_description:mail_show_follower.field_res_config_settings__show_internal_users_cc +msgid "Show Internal Users CC" +msgstr "Afficher les utilisateurs internes en « Copie à (CC) »" + +#. module: mail_show_follower +#: model_terms:ir.ui.view,arch_db:mail_show_follower.res_config_settings_view_form +msgid "Show Internal Users on CC" +msgstr "" + +#. module: mail_show_follower +#: model:ir.model.fields,field_description:mail_show_follower.field_res_users__show_in_cc +msgid "Show in CC" +msgstr "Afficher dans « Copie à (CC) »" + +#. module: mail_show_follower +#: model:ir.model.fields,help:mail_show_follower.field_res_company__show_followers_partner_format +#: model:ir.model.fields,help:mail_show_follower.field_res_config_settings__show_followers_partner_format +msgid "" +"Supported parameters:\n" +"%(partner_name)s = Partner Name\n" +"%(partner_email)s = Partner Email\n" +"%(partner_email_domain)s = Partner Email Domain" +msgstr "" + +#. module: mail_show_follower +#: model:ir.model.fields,field_description:mail_show_follower.field_res_company__show_followers_message_response_warning +#: model:ir.model.fields,field_description:mail_show_follower.field_res_config_settings__show_followers_message_response_warning +msgid "Text 'Replies'" +msgstr "" + +#. module: mail_show_follower +#: model:ir.model.fields,field_description:mail_show_follower.field_res_company__show_followers_message_sent_to +#: model:ir.model.fields,field_description:mail_show_follower.field_res_config_settings__show_followers_message_sent_to +msgid "Text 'Sent to'" +msgstr "" + +#. module: mail_show_follower +#: model_terms:ir.ui.view,arch_db:mail_show_follower.res_config_settings_view_form +msgid "This message has been sent to" +msgstr "" + +#. module: mail_show_follower +#: model:ir.model,name:mail_show_follower.model_res_users +msgid "Users" +msgstr "Utilisateurs" + +#~ msgid "Add internal users in cc mails details" +#~ msgstr "" +#~ "Ajouter les utilisateurs internes dans l'entête « Copie à (CC) » des e-" +#~ "mails" diff --git a/mail_show_follower/i18n/mail_show_follower.pot b/mail_show_follower/i18n/mail_show_follower.pot new file mode 100644 index 0000000000..f861e8191a --- /dev/null +++ b/mail_show_follower/i18n/mail_show_follower.pot @@ -0,0 +1,103 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_show_follower +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: mail_show_follower +#: model_terms:ir.ui.view,arch_db:mail_show_follower.res_config_settings_view_form +msgid "%(partner_name)s <%(partner_email)s>" +msgstr "" + +#. module: mail_show_follower +#: model:ir.model,name:mail_show_follower.model_res_company +msgid "Companies" +msgstr "" + +#. module: mail_show_follower +#: model:ir.model,name:mail_show_follower.model_res_config_settings +msgid "Config Settings" +msgstr "" + +#. module: mail_show_follower +#: model:ir.model.fields,field_description:mail_show_follower.field_res_config_settings__show_followers_message_preview +msgid "Message preview" +msgstr "" + +#. module: mail_show_follower +#: model_terms:ir.ui.view,arch_db:mail_show_follower.res_config_settings_view_form +msgid "Notice: Replies to this email will be sent to all recipients." +msgstr "" + +#. module: mail_show_follower +#: model:ir.model,name:mail_show_follower.model_mail_mail +msgid "Outgoing Mails" +msgstr "" + +#. module: mail_show_follower +#: model:ir.model.fields,field_description:mail_show_follower.field_res_company__show_followers_partner_format +#: model:ir.model.fields,field_description:mail_show_follower.field_res_config_settings__show_followers_partner_format +msgid "Partner format" +msgstr "" + +#. module: mail_show_follower +#: model_terms:ir.ui.view,arch_db:mail_show_follower.res_config_settings_view_form +msgid "Show Followers on mails" +msgstr "" + +#. module: mail_show_follower +#: model:ir.model.fields,field_description:mail_show_follower.field_res_company__show_internal_users_cc +#: model:ir.model.fields,field_description:mail_show_follower.field_res_config_settings__show_internal_users_cc +msgid "Show Internal Users CC" +msgstr "" + +#. module: mail_show_follower +#: model_terms:ir.ui.view,arch_db:mail_show_follower.res_config_settings_view_form +msgid "Show Internal Users on CC" +msgstr "" + +#. module: mail_show_follower +#: model:ir.model.fields,field_description:mail_show_follower.field_res_users__show_in_cc +msgid "Show in CC" +msgstr "" + +#. module: mail_show_follower +#: model:ir.model.fields,help:mail_show_follower.field_res_company__show_followers_partner_format +#: model:ir.model.fields,help:mail_show_follower.field_res_config_settings__show_followers_partner_format +msgid "" +"Supported parameters:\n" +"%(partner_name)s = Partner Name\n" +"%(partner_email)s = Partner Email\n" +"%(partner_email_domain)s = Partner Email Domain" +msgstr "" + +#. module: mail_show_follower +#: model:ir.model.fields,field_description:mail_show_follower.field_res_company__show_followers_message_response_warning +#: model:ir.model.fields,field_description:mail_show_follower.field_res_config_settings__show_followers_message_response_warning +msgid "Text 'Replies'" +msgstr "" + +#. module: mail_show_follower +#: model:ir.model.fields,field_description:mail_show_follower.field_res_company__show_followers_message_sent_to +#: model:ir.model.fields,field_description:mail_show_follower.field_res_config_settings__show_followers_message_sent_to +msgid "Text 'Sent to'" +msgstr "" + +#. module: mail_show_follower +#: model_terms:ir.ui.view,arch_db:mail_show_follower.res_config_settings_view_form +msgid "This message has been sent to" +msgstr "" + +#. module: mail_show_follower +#: model:ir.model,name:mail_show_follower.model_res_users +msgid "Users" +msgstr "" diff --git a/mail_show_follower/i18n/nl.po b/mail_show_follower/i18n/nl.po new file mode 100644 index 0000000000..ad2f1d2d1f --- /dev/null +++ b/mail_show_follower/i18n/nl.po @@ -0,0 +1,111 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_show_follower +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-07-22 17:20+0000\n" +"PO-Revision-Date: 2023-07-22 19:23+0200\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: nl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" +"X-Generator: Poedit 3.3.1\n" + +#. module: mail_show_follower +#: model_terms:ir.ui.view,arch_db:mail_show_follower.res_config_settings_view_form +msgid "%(partner_name)s <%(partner_email)s>" +msgstr "" + +#. module: mail_show_follower +#: model:ir.model,name:mail_show_follower.model_res_company +msgid "Companies" +msgstr "Bedrijven" + +#. module: mail_show_follower +#: model:ir.model,name:mail_show_follower.model_res_config_settings +msgid "Config Settings" +msgstr "Configuratie instellingen" + +#. module: mail_show_follower +#: model:ir.model.fields,field_description:mail_show_follower.field_res_config_settings__show_followers_message_preview +msgid "Message preview" +msgstr "Bericht voorbeeld" + +#. module: mail_show_follower +#: model_terms:ir.ui.view,arch_db:mail_show_follower.res_config_settings_view_form +msgid "Notice: Replies to this email will be sent to all recipients." +msgstr "Opmerking: antwoorden op deze e-mail worden naar alle ontvangers verzonden." + +#. module: mail_show_follower +#: model:ir.model,name:mail_show_follower.model_mail_mail +msgid "Outgoing Mails" +msgstr "Uitgaande e-mails" + +#. module: mail_show_follower +#: model:ir.model.fields,field_description:mail_show_follower.field_res_company__show_followers_partner_format +#: model:ir.model.fields,field_description:mail_show_follower.field_res_config_settings__show_followers_partner_format +msgid "Partner format" +msgstr "Partner formaat" + +#. module: mail_show_follower +#: model_terms:ir.ui.view,arch_db:mail_show_follower.res_config_settings_view_form +msgid "Show Followers on mails" +msgstr "Toon volgers op e-mails" + +#. module: mail_show_follower +#: model:ir.model.fields,field_description:mail_show_follower.field_res_company__show_internal_users_cc +#: model:ir.model.fields,field_description:mail_show_follower.field_res_config_settings__show_internal_users_cc +msgid "Show Internal Users CC" +msgstr "Toon interne gebruikers CC" + +#. module: mail_show_follower +#: model_terms:ir.ui.view,arch_db:mail_show_follower.res_config_settings_view_form +msgid "Show Internal Users on CC" +msgstr "Toon interne gebruikers in CC" + +#. module: mail_show_follower +#: model:ir.model.fields,field_description:mail_show_follower.field_res_users__show_in_cc +msgid "Show in CC" +msgstr "Tonen in CC" + +#. module: mail_show_follower +#: model:ir.model.fields,help:mail_show_follower.field_res_company__show_followers_partner_format +#: model:ir.model.fields,help:mail_show_follower.field_res_config_settings__show_followers_partner_format +msgid "" +"Supported parameters:\n" +"%(partner_name)s = Partner Name\n" +"%(partner_email)s = Partner Email\n" +"%(partner_email_domain)s = Partner Email Domain" +msgstr "" +"Ondersteunende parameters:\n" +"%(partner_name)s = Relatie naam\n" +"%(partner_email)s = Relatie Email\n" +"%(partner_email_domain)s = Relatie email domein" + +#. module: mail_show_follower +#: model:ir.model.fields,field_description:mail_show_follower.field_res_company__show_followers_message_response_warning +#: model:ir.model.fields,field_description:mail_show_follower.field_res_config_settings__show_followers_message_response_warning +msgid "Text 'Replies'" +msgstr "Tekst 'Antwoorden'" + +#. module: mail_show_follower +#: model:ir.model.fields,field_description:mail_show_follower.field_res_company__show_followers_message_sent_to +#: model:ir.model.fields,field_description:mail_show_follower.field_res_config_settings__show_followers_message_sent_to +msgid "Text 'Sent to'" +msgstr "Tekst 'Verzonden naar'" + +#. module: mail_show_follower +#: model_terms:ir.ui.view,arch_db:mail_show_follower.res_config_settings_view_form +msgid "This message has been sent to" +msgstr "Dit bericht is verzonden naar" + +#. module: mail_show_follower +#: model:ir.model,name:mail_show_follower.model_res_users +msgid "User" +msgstr "Gebruiker" diff --git a/mail_show_follower/models/__init__.py b/mail_show_follower/models/__init__.py new file mode 100644 index 0000000000..9b936c42df --- /dev/null +++ b/mail_show_follower/models/__init__.py @@ -0,0 +1,4 @@ +from . import mail_mail +from . import res_company +from . import res_config_settings +from . import res_users diff --git a/mail_show_follower/models/mail_mail.py b/mail_show_follower/models/mail_mail.py new file mode 100644 index 0000000000..4e69087bce --- /dev/null +++ b/mail_show_follower/models/mail_mail.py @@ -0,0 +1,171 @@ +from markupsafe import Markup + +from odoo import api, models, tools + + +class MailMail(models.Model): + _inherit = "mail.mail" + + @api.model + def _build_cc_text(self, partners): + if not partners: + return "" + + def get_ctx_param(ctx_key, default_parm): + if ctx_key in self.env.context: + return self.env.context[ctx_key] + return default_parm + + def remove_p(markup_txt): + if markup_txt.startswith("

") and markup_txt.endswith("

"): + return markup_txt[3:-4] + return markup_txt + + company = self.env.company + partner_format = get_ctx_param( + "partner_format", company.show_followers_partner_format + ) + msg_sent_to = get_ctx_param( + "msg_sent_to", company.show_followers_message_sent_to + ) + msg_warn = get_ctx_param( + "msg_warn", company.show_followers_message_response_warning + ) + msg_back_color = get_ctx_param( + "msg_back_color", company.show_followers_message_background_color + ) + msg_font_color = get_ctx_param( + "msg_font_color", company.show_followers_message_font_color + ) + partner_message = ", ".join( + [ + partner_format + % { + # Supported parameters + "partner_name": p.name, + "partner_email": p.email, + "partner_email_domain": tools.email_domain_extract(p.email), + } + for p in partners + ] + ) + full_text = """ +
+ {msg_sent_to} {partner_message} + {rc}{msg_warn} +
+ """.format( + msg_font_color=msg_font_color or "#000000", + msg_back_color=msg_back_color or "#EBEBEB", + msg_sent_to=remove_p(msg_sent_to), + partner_message=Markup.escape(partner_message), + rc=msg_warn.striptags() and "
" or "", + msg_warn=msg_warn.striptags() and remove_p(msg_warn) or "", + ) + return full_text + + def _send(self, auto_commit=False, raise_exception=False, smtp_session=None, + alias_domain_id=False, mail_server=False, post_send_callback=None): + group_portal = self.env.ref("base.group_portal") + for mail_id in self.ids: + mail = self.browse(mail_id) + message_recipients = self.search( + [ + ("message_id", "=", mail.message_id), + ] + ).mapped("recipient_ids") + # if the email has a model, id and it belongs to the portal group + if (mail.model and mail.res_id and group_portal + and not mail.subtype_id.internal): + obj = self.env[mail.model].browse(mail.res_id) + # those partners are obtained, who do not have a user and + # if they do it must be a portal, we exclude internal + # users of the system. + if hasattr(obj, "message_follower_ids"): + partners_obj = ( + obj.message_follower_ids.mapped("partner_id") + | message_recipients + ) + # internal partners + user_partner_ids = ( + self.env["res.users"] + .search( + [ + ("active", "in", (True, False)), + ("show_in_cc", "=", False), + ] + ) + .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.mapped("groups_id") + ) + ) + ) + if partners_len > 1: + # get partners + 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 + ) + if cc_internal: + partners = partners_obj.filtered( + lambda x: x.id not in user_partner_ids + and ( + not x.user_ids + or any(x.mapped("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.mapped("groups_id") + ) + ) + partners = partners.filtered( + lambda x: not x.user_ids + or x.user_ids # otherwise, email is not sent + and "email" in x.user_ids.mapped("notification_type") + ) + # set proper lang for recipients + langs = list( + filter( + bool, + mail.mapped("recipient_ids.lang") + + [ + mail.author_id.lang, + self.env.company.partner_id.lang, + ], + ) + ) + # get show follower text + final_cc = mail.with_context( + lang=langs and langs[0] + )._build_cc_text(partners) + # 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()._send( + auto_commit=auto_commit, + raise_exception=raise_exception, + smtp_session=smtp_session, + alias_domain_id=False, + mail_server=mail_server, + post_send_callback=post_send_callback + ) diff --git a/mail_show_follower/models/res_company.py b/mail_show_follower/models/res_company.py new file mode 100644 index 0000000000..6230ea6a52 --- /dev/null +++ b/mail_show_follower/models/res_company.py @@ -0,0 +1,40 @@ +from odoo import fields, models + + +class ResCompany(models.Model): + _inherit = "res.company" + + show_internal_users_cc = fields.Boolean( + string="Show Internal Users CC", + default=True, + ) + show_followers_message_sent_to = fields.Html( + string="Text 'Sent to'", + translate=True, + default="This message has been sent to", + ) + show_followers_partner_format = fields.Char( + string="Partner format", + default="%(partner_name)s", + help="Supported parameters:\n" + "%(partner_name)s = Partner Name\n" + "%(partner_email)s = Partner Email\n" + "%(partner_email_domain)s = Partner Email Domain", + ) + show_followers_message_response_warning = fields.Html( + string="Text 'Replies'", + translate=True, + default="Notice: Replies to this email will be sent to all recipients", + ) + show_followers_message_background_color = fields.Char( + "Follower message Background Color", + readonly=False, + store=True, + default="#EBEBEB" + ) + show_followers_message_font_color = fields.Char( + "Follower message font Color", + readonly=False, + store=True, + default="#000000" + ) diff --git a/mail_show_follower/models/res_config_settings.py b/mail_show_follower/models/res_config_settings.py new file mode 100644 index 0000000000..e08e860287 --- /dev/null +++ b/mail_show_follower/models/res_config_settings.py @@ -0,0 +1,63 @@ +from odoo import api, fields, models + + +class ResConfigSettings(models.TransientModel): + _inherit = "res.config.settings" + + show_internal_users_cc = fields.Boolean( + related="company_id.show_internal_users_cc", + readonly=False, + ) + show_followers_message_sent_to = fields.Html( + related="company_id.show_followers_message_sent_to", + readonly=False, + ) + show_followers_partner_format = fields.Char( + related="company_id.show_followers_partner_format", + readonly=False, + help="Supported parameters:\n" + "%(partner_name)s = Partner Name\n" + "%(partner_email)s = Partner Email\n" + "%(partner_email_domain)s = Partner Email Domain", + ) + show_followers_message_response_warning = fields.Html( + related="company_id.show_followers_message_response_warning", + readonly=False, + ) + show_followers_message_preview = fields.Html( + string="Message preview", + readonly=True, + store=False, + ) + show_followers_message_background_color = fields.Char( + related='company_id.show_followers_message_background_color', + readonly=False + ) + show_followers_message_font_color = fields.Char( + related='company_id.show_followers_message_font_color', + readonly=False + ) + + @api.onchange( + "show_followers_message_sent_to", + "show_followers_partner_format", + "show_followers_message_response_warning", + "show_followers_message_background_color", + "show_followers_message_font_color" + ) + def onchange_show_followers_message_preview(self): + self.show_followers_message_preview = ( + self.env["mail.mail"] + .with_context( + # Use current data before + partner_format=self.show_followers_partner_format or "", + msg_sent_to=self.show_followers_message_sent_to or "", + msg_warn=self.show_followers_message_response_warning or "", + msg_back_color=self.show_followers_message_background_color or "#EBEBEB", + msg_font_color=self.show_followers_message_font_color or "#E0E2E6" + ) + ._build_cc_text( + # Sample partners + self.env["res.partner"].search([("email", "!=", False)], limit=3), + ) + ) diff --git a/mail_show_follower/models/res_users.py b/mail_show_follower/models/res_users.py new file mode 100644 index 0000000000..4f9d71f3c5 --- /dev/null +++ b/mail_show_follower/models/res_users.py @@ -0,0 +1,7 @@ +from odoo import fields, models + + +class ResUser(models.Model): + _inherit = "res.users" + + show_in_cc = fields.Boolean(string="Show in CC", default=True) diff --git a/mail_show_follower/readme/CONFIGURE.rst b/mail_show_follower/readme/CONFIGURE.rst new file mode 100644 index 0000000000..b9417c8679 --- /dev/null +++ b/mail_show_follower/readme/CONFIGURE.rst @@ -0,0 +1,9 @@ +To configure this module, you need to: + +#. Go General settings/Discuss/Show Followers on mails/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. +#. 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 on mails/Follower message Background Color and choose desired background color +#. Go General settings/Discuss/Show Followers on mails/Follower message font Color and choose desired font color diff --git a/mail_show_follower/readme/CONTRIBUTORS.rst b/mail_show_follower/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..5aa167943e --- /dev/null +++ b/mail_show_follower/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* Valentin Vinagre +* Lorenzo Battistini +* Eduardo de Miguel diff --git a/mail_show_follower/readme/DESCRIPTION.rst b/mail_show_follower/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..19d47011dc --- /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 0000000000..7fddf97f86 --- /dev/null +++ b/mail_show_follower/readme/USAGE.rst @@ -0,0 +1,5 @@ +To use this module, you need to: + +#. Send an email from any document of odoo. + +Be aware that the extra message only is shown if there are multiple receipients for the sent message, and not all are set as Do not show in CC (for internal users) diff --git a/mail_show_follower/requirements.txt b/mail_show_follower/requirements.txt new file mode 100644 index 0000000000..5d1143fb08 --- /dev/null +++ b/mail_show_follower/requirements.txt @@ -0,0 +1 @@ +markupsafe==2.0.1 diff --git a/mail_show_follower/static/description/icon.png b/mail_show_follower/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/mail_show_follower/static/description/icon.png differ diff --git a/mail_show_follower/static/description/index.html b/mail_show_follower/static/description/index.html new file mode 100644 index 0000000000..82c33be9d9 --- /dev/null +++ b/mail_show_follower/static/description/index.html @@ -0,0 +1,453 @@ + + + + + +Mail Show Follower + + + +
+

Mail Show Follower

+ + +

Beta License: AGPL-3 OCA/social Translate me on Weblate Try me on Runbot

+

This module extends the functionality of mailing to show the document followers in head of the mails. +In the cc, only appear when:

+
    +
  1. The followers only count if are contacts or external users (Inner Followers will be discriminated)
  2. +
  3. The number of followers are more than 1.
  4. +
+

Table of contents

+ +
+

Configuration

+

To configure this module, you need to:

+
    +
  1. Go General settings/Discuss/Show Followers on mails/Show Internal Users CC and set if want to show or not internal users in cc details.
  2. +
  3. 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.
  4. +
  5. Go General settings/Discuss/Show Followers on mails/Text ‘Sent to’ and set the initial part of the message.
  6. +
  7. Go General settings/Discuss/Show Followers on mails/Partner format and choose desired fields to show on CC recipients.
  8. +
  9. Go General settings/Discuss/Show Followers on mails/Text ‘Replies’ and choose desired warn message
  10. +
  11. Go General settings/Discuss/Show Followers on mails/Follower message Background Color and choose desired background color
  12. +
  13. Go General settings/Discuss/Show Followers on mails/Follower message font Color and choose desired font color
  14. + +
+
+
+

Usage

+

To use this module, you need to:

+
    +
  1. Send an email from any document of odoo.
  2. +
+Note that the extra message will only be displayed if there are multiple recipients, + and not all are marked as "Do not show in CC" (for internal users). Also the extra display message is placed AFTER sending from Odoo. So you need to test the feature with a mail server setup, or a mailcatcher function. +
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Sygel
  • +
  • Moduon
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

Current maintainer:

+

yajo

+

This module is part of the OCA/social project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/mail_show_follower/views/res_config_settings.xml b/mail_show_follower/views/res_config_settings.xml new file mode 100644 index 0000000000..efe770b9b0 --- /dev/null +++ b/mail_show_follower/views/res_config_settings.xml @@ -0,0 +1,64 @@ + + + + res.config.settings.view.form.inherit.mail.show.follower + res.config.settings + + + +
+
+
+
+
+ + +
+
+
+
+
+
+
diff --git a/mail_show_follower/views/res_users.xml b/mail_show_follower/views/res_users.xml new file mode 100644 index 0000000000..a05a6ebda7 --- /dev/null +++ b/mail_show_follower/views/res_users.xml @@ -0,0 +1,13 @@ + + + + view.users.form.mail.show.follower + res.users + + + + + + + +