commit
ebfd9bcaa4
@ -41,8 +41,11 @@ 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 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
|
||||
=====
|
||||
@ -68,12 +71,14 @@ Authors
|
||||
~~~~~~~
|
||||
|
||||
* Sygel
|
||||
* Moduon
|
||||
|
||||
Contributors
|
||||
~~~~~~~~~~~~
|
||||
|
||||
* Valentin Vinagre <valentin.vinagre@sygel.es>
|
||||
* Lorenzo Battistini
|
||||
* Eduardo de Miguel <edu@moduon.team>
|
||||
|
||||
Maintainers
|
||||
~~~~~~~~~~~
|
||||
|
@ -1,13 +1,14 @@
|
||||
# Copyright 2020 Valentin Vinagre <valentin.vinagre@sygel.es>
|
||||
# Copyright 2022 Eduardo de Miguel <edu@moduon.team>
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
{
|
||||
"name": "Mail Show Follower",
|
||||
"summary": "Show CC document followers in mails.",
|
||||
"version": "15.0.1.0.0",
|
||||
"version": "15.0.1.1.0",
|
||||
"category": "Mail",
|
||||
"website": "https://github.com/OCA/social",
|
||||
"author": "Sygel, Odoo Community Association (OCA)",
|
||||
"author": "Sygel, Moduon, Odoo Community Association (OCA)",
|
||||
"license": "AGPL-3",
|
||||
"application": False,
|
||||
"installable": True,
|
||||
|
@ -1,16 +1,64 @@
|
||||
from odoo import models
|
||||
from markupsafe import Markup
|
||||
|
||||
from odoo import api, models, tools
|
||||
|
||||
|
||||
class MailMail(models.Model):
|
||||
_inherit = "mail.mail"
|
||||
|
||||
def _send(self, auto_commit=False, raise_exception=False, smtp_session=None):
|
||||
plain_text = (
|
||||
'<div summary="o_mail_notification" style="padding: 0px; '
|
||||
'font-size: 10px;"><b>CC</b>: %s<hr style="background-color:'
|
||||
"rgb(204,204,204);border:medium none;clear:both;display:block;"
|
||||
'font-size:0px;min-height:1px;line-height:0; margin:4px 0 12px 0;"></div>'
|
||||
@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("<p>") and markup_txt.endswith("</p>"):
|
||||
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
|
||||
)
|
||||
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 = """
|
||||
<div summary='o_mail_notification' style='padding:5px;
|
||||
margin:10px 0px 10px 0px;font-size:13px;border-radius:5px;
|
||||
font-family:Arial;border:1px solid #E0E2E6;background-color:#EBEBEB;'>
|
||||
{msg_sent_to} {partner_message}
|
||||
{rc}{msg_warn}
|
||||
</div>
|
||||
""".format(
|
||||
msg_sent_to=remove_p(msg_sent_to),
|
||||
partner_message=Markup.escape(partner_message),
|
||||
rc=msg_warn.striptags() and "<br/>" 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):
|
||||
group_portal = self.env.ref("base.group_portal")
|
||||
for mail_id in self.ids:
|
||||
mail = self.browse(mail_id)
|
||||
@ -73,13 +121,21 @@ class MailMail(models.Model):
|
||||
or x.user_ids # otherwise, email is not sent
|
||||
and "email" in x.user_ids.mapped("notification_type")
|
||||
)
|
||||
# get names and emails
|
||||
final_cc = None
|
||||
mails = ""
|
||||
for p in partners:
|
||||
mails += "%s <%s>, " % (p.name, p.email)
|
||||
# join texts
|
||||
final_cc = plain_text % (mails[:-2])
|
||||
# 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
|
||||
|
@ -5,5 +5,24 @@ class ResCompany(models.Model):
|
||||
_inherit = "res.company"
|
||||
|
||||
show_internal_users_cc = fields.Boolean(
|
||||
string="Show Internal Users CC", default=True
|
||||
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",
|
||||
)
|
||||
|
@ -1,11 +1,51 @@
|
||||
from odoo import fields, models
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class ResConfigSettings(models.TransientModel):
|
||||
_inherit = "res.config.settings"
|
||||
|
||||
show_internal_users_cc = fields.Boolean(
|
||||
string="Show Internal Users CC",
|
||||
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,
|
||||
)
|
||||
|
||||
@api.onchange(
|
||||
"show_followers_message_sent_to",
|
||||
"show_followers_partner_format",
|
||||
"show_followers_message_response_warning",
|
||||
)
|
||||
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 "",
|
||||
)
|
||||
._build_cc_text(
|
||||
# Sample partners
|
||||
self.env["res.partner"].search([("email", "!=", False)], limit=3),
|
||||
)
|
||||
)
|
||||
|
@ -1,4 +1,7 @@
|
||||
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 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
|
||||
|
@ -1,2 +1,3 @@
|
||||
* Valentin Vinagre <valentin.vinagre@sygel.es>
|
||||
* Lorenzo Battistini
|
||||
* Eduardo de Miguel <edu@moduon.team>
|
||||
|
@ -3,7 +3,7 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
|
||||
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
|
||||
<title>Mail Show Follower</title>
|
||||
<style type="text/css">
|
||||
|
||||
@ -392,8 +392,11 @@ In the cc, only appear when:</p>
|
||||
<h1><a class="toc-backref" href="#id1">Configuration</a></h1>
|
||||
<p>To configure this module, you need to:</p>
|
||||
<ol class="arabic simple">
|
||||
<li>Go General settings/Discuss/Show Internal Users CC and set if want to show or not internal users in cc details.</li>
|
||||
<li>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.</li>
|
||||
<li>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.</li>
|
||||
<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>
|
||||
</ol>
|
||||
</div>
|
||||
<div class="section" id="usage">
|
||||
@ -417,6 +420,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
||||
<h2><a class="toc-backref" href="#id5">Authors</a></h2>
|
||||
<ul class="simple">
|
||||
<li>Sygel</li>
|
||||
<li>Moduon</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="contributors">
|
||||
@ -424,6 +428,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
||||
<ul class="simple">
|
||||
<li>Valentin Vinagre <<a class="reference external" href="mailto:valentin.vinagre@sygel.es">valentin.vinagre@sygel.es</a>></li>
|
||||
<li>Lorenzo Battistini</li>
|
||||
<li>Eduardo de Miguel <<a class="reference external" href="mailto:edu@moduon.team">edu@moduon.team</a>></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="maintainers">
|
||||
|
@ -10,12 +10,68 @@
|
||||
<div id="emails" position="inside">
|
||||
<div class="col-12 col-lg-6 o_setting_box">
|
||||
<div class="o_setting_left_pane">
|
||||
<field name="show_internal_users_cc" />
|
||||
</div>
|
||||
<div class="o_setting_right_pane">
|
||||
<label for="show_internal_users_cc" />
|
||||
<div class="text-muted" id="show_internal_users_cc">
|
||||
Add internal users in cc mails details
|
||||
<div class="content-group">
|
||||
<label
|
||||
for="show_internal_users_cc"
|
||||
string="Show Followers on mails"
|
||||
/>
|
||||
<div>
|
||||
<div>
|
||||
<label
|
||||
for="show_internal_users_cc"
|
||||
class="o_light_label"
|
||||
string="Show Internal Users on CC"
|
||||
/>
|
||||
<field name="show_internal_users_cc" />
|
||||
</div>
|
||||
<div>
|
||||
<label
|
||||
for="show_followers_message_sent_to"
|
||||
class="o_light_label"
|
||||
style="vertical-align: top;"
|
||||
/>
|
||||
<field
|
||||
name="show_followers_message_sent_to"
|
||||
placeholder="This message has been sent to"
|
||||
style="display:inline-block;"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label
|
||||
for="show_followers_partner_format"
|
||||
class="o_light_label"
|
||||
style="vertical-align: top;"
|
||||
/>
|
||||
<field
|
||||
name="show_followers_partner_format"
|
||||
placeholder="%%(partner_name)s <%%(partner_email)s>"
|
||||
style="display:inline-block;"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label
|
||||
for="show_followers_message_response_warning"
|
||||
class="o_light_label"
|
||||
style="vertical-align: top;"
|
||||
/>
|
||||
<field
|
||||
name="show_followers_message_response_warning"
|
||||
placeholder="Notice: Replies to this email will be sent to all recipients."
|
||||
style="display:inline-block;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<label
|
||||
for="show_followers_message_preview"
|
||||
class="text-muted"
|
||||
/>
|
||||
<field
|
||||
name="show_followers_message_preview"
|
||||
style="width:100%;"
|
||||
widget="html"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user