diff --git a/mail_show_follower/__manifest__.py b/mail_show_follower/__manifest__.py
index a29d0c6..a35d9ed 100755
--- a/mail_show_follower/__manifest__.py
+++ b/mail_show_follower/__manifest__.py
@@ -11,12 +11,6 @@
"license": "AGPL-3",
"application": False,
"installable": True,
- "depends": [
- "base",
- "mail"
- ],
- "data": [
- "views/res_config_settings.xml",
- "views/res_users.xml"
- ],
+ "depends": ["base", "mail"],
+ "data": ["views/res_config_settings.xml", "views/res_users.xml"],
}
diff --git a/mail_show_follower/models/mail_mail.py b/mail_show_follower/models/mail_mail.py
index 4e2e420..27d3bf1 100755
--- a/mail_show_follower/models/mail_mail.py
+++ b/mail_show_follower/models/mail_mail.py
@@ -1,4 +1,4 @@
-from odoo import models, api
+from odoo import api, models
class MailMail(models.Model):
@@ -9,10 +9,10 @@ class MailMail(models.Model):
plain_text = (
'
CC: %s
'
)
- group_portal = self.env.ref('base.group_portal')
+ group_portal = self.env.ref("base.group_portal")
for mail_id in self.ids:
mail = self.browse(mail_id)
# if the email has a model, id and it belongs to the portal group
@@ -22,19 +22,29 @@ class MailMail(models.Model):
# 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')
+ partners_obj = obj.message_follower_ids.mapped("partner_id")
# 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")
- )))
+ 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
@@ -43,28 +53,28 @@ class MailMail(models.Model):
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.mapped("groups_id")
+ 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
+ lambda x: not x.user_ids
or
# otherwise, email is not sent
- x.user_ids and "email" in x.user_ids.mapped(
- "notification_type")
+ x.user_ids
+ and "email" in x.user_ids.mapped("notification_type")
)
# get names and emails
final_cc = None
@@ -77,6 +87,7 @@ class MailMail(models.Model):
# 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
+ 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 d273a8c..fdbc33e 100644
--- a/mail_show_follower/models/res_company.py
+++ b/mail_show_follower/models/res_company.py
@@ -1,10 +1,9 @@
-from odoo import models, fields
+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
+ string="Show Internal Users CC", default=True
)
diff --git a/mail_show_follower/models/res_config_settings.py b/mail_show_follower/models/res_config_settings.py
index e15b818..5b46dde 100644
--- a/mail_show_follower/models/res_config_settings.py
+++ b/mail_show_follower/models/res_config_settings.py
@@ -2,10 +2,10 @@ from odoo import fields, models
class ResConfigSettings(models.TransientModel):
- _inherit = 'res.config.settings'
+ _inherit = "res.config.settings"
show_internal_users_cc = fields.Boolean(
- string='Show Internal Users CC',
- related='company_id.show_internal_users_cc',
- readonly=False
+ string="Show Internal Users CC",
+ related="company_id.show_internal_users_cc",
+ readonly=False,
)
diff --git a/mail_show_follower/models/res_users.py b/mail_show_follower/models/res_users.py
index 7e30a44..4f9d71f 100644
--- a/mail_show_follower/models/res_users.py
+++ b/mail_show_follower/models/res_users.py
@@ -1,10 +1,7 @@
-from odoo import models, fields
+from odoo import fields, models
class ResUser(models.Model):
_inherit = "res.users"
- show_in_cc = fields.Boolean(
- string='Show in CC',
- default=True
- )
+ show_in_cc = fields.Boolean(string="Show in CC", default=True)
diff --git a/mail_show_follower/views/res_config_settings.xml b/mail_show_follower/views/res_config_settings.xml
index 84dc70f..7248903 100644
--- a/mail_show_follower/views/res_config_settings.xml
+++ b/mail_show_follower/views/res_config_settings.xml
@@ -1,17 +1,19 @@
-
+
- res.config.settings.view.form.inherit.mail.show.follower
+ res.config.settings.view.form.inherit.mail.show.follower
res.config.settings
-
+
-
+
-
+
Add internal users in cc mails details
diff --git a/mail_show_follower/views/res_users.xml b/mail_show_follower/views/res_users.xml
index 1a60403..a05a6eb 100644
--- a/mail_show_follower/views/res_users.xml
+++ b/mail_show_follower/views/res_users.xml
@@ -1,12 +1,12 @@
-
+
view.users.form.mail.show.follower
res.users
-
+
-
+
diff --git a/setup/mail_show_follower/odoo/addons/mail_show_follower b/setup/mail_show_follower/odoo/addons/mail_show_follower
new file mode 120000
index 0000000..64a2d5f
--- /dev/null
+++ b/setup/mail_show_follower/odoo/addons/mail_show_follower
@@ -0,0 +1 @@
+../../../../mail_show_follower
\ No newline at end of file
diff --git a/setup/mail_show_follower/setup.py b/setup/mail_show_follower/setup.py
new file mode 100644
index 0000000..28c57bb
--- /dev/null
+++ b/setup/mail_show_follower/setup.py
@@ -0,0 +1,6 @@
+import setuptools
+
+setuptools.setup(
+ setup_requires=['setuptools-odoo'],
+ odoo_addon=True,
+)