diff --git a/addons/auth_totp/__manifest__.py b/addons/auth_totp/__manifest__.py
index e350d36c9b0..dd70ff54d73 100644
--- a/addons/auth_totp/__manifest__.py
+++ b/addons/auth_totp/__manifest__.py
@@ -14,14 +14,13 @@ Note: logically, two-factor prevents password-based RPC access for users
where it is enabled. In order to be able to execute RPC scripts, the user
can setup API keys to replace their main password.
""",
- 'depends': ['web', 'mail'],
+ 'depends': ['web'],
'category': 'Extra Tools',
'auto_install': True,
'data': [
'security/security.xml',
'security/ir.model.access.csv',
'data/ir_action_data.xml',
- 'data/mail_template_data.xml',
'views/res_users_views.xml',
'views/templates.xml',
'wizard/auth_totp_wizard_views.xml',
diff --git a/addons/auth_totp/data/ir_action_data.xml b/addons/auth_totp/data/ir_action_data.xml
index 9543556ed08..2dcf86157d7 100644
--- a/addons/auth_totp/data/ir_action_data.xml
+++ b/addons/auth_totp/data/ir_action_data.xml
@@ -1,18 +1,5 @@
-
-
- Invite to use two-factor authentication
-
-
- list
- code
-
- action = records.action_totp_invite()
-
-
-
-
Disable two-factor authentication
@@ -25,16 +12,4 @@
-
-
-
- Open two-factor authentication configuration
-
- code
-
-user = env.user
-action = user.action_open_my_account_settings()
-
-
-
diff --git a/addons/auth_totp/models/res_users.py b/addons/auth_totp/models/res_users.py
index 8e19092de32..2ec48edf39b 100644
--- a/addons/auth_totp/models/res_users.py
+++ b/addons/auth_totp/models/res_users.py
@@ -41,16 +41,6 @@ class Users(models.Model):
for r, v in zip(self, self.sudo()):
r.totp_enabled = bool(v.totp_secret)
- def action_open_my_account_settings(self):
- action = {
- "name": _("Account Security"),
- "type": "ir.actions.act_window",
- "res_model": "res.users",
- "views": [[self.env.ref('auth_totp.res_users_view_form_security').id, "form"]],
- "res_id": self.id,
- }
- return action
-
def _rpc_api_keys_only(self):
# 2FA enabled means we can't allow password-based RPC
self.ensure_one()
@@ -89,32 +79,6 @@ class Users(models.Model):
_logger.info("2FA enable: SUCCESS for %s %r", self, self.login)
return True
- def get_totp_invite_url(self):
- return '/web#action=auth_totp.action_activate_two_factor_authentication'
-
- def action_totp_invite(self):
- invite_template = self.env.ref('auth_totp.mail_template_totp_invite')
- users_to_invite = self.sudo().filtered(lambda user: not user.totp_secret)
- for user in users_to_invite:
- email_values = {
- 'email_from': self.env.user.email_formatted,
- 'author_id': self.env.user.partner_id.id,
- }
- invite_template.send_mail(user.id, force_send=True, email_values=email_values,
- notif_layout='mail.mail_notification_light')
-
- # Display a confirmation toaster
- return {
- 'type': 'ir.actions.client',
- 'tag': 'display_notification',
- 'params': {
- 'type': 'info',
- 'sticky': False,
- 'message': _("Invitation to use two-factor authentication sent for the following user(s): %s",
- ', '.join(users_to_invite.mapped('name'))),
- }
- }
-
@check_identity
def action_totp_disable(self):
logins = ', '.join(map(repr, self.mapped('login')))
diff --git a/addons/auth_totp/views/res_users_views.xml b/addons/auth_totp/views/res_users_views.xml
index 5a268addd1e..9ee3e7a328b 100644
--- a/addons/auth_totp/views/res_users_views.xml
+++ b/addons/auth_totp/views/res_users_views.xml
@@ -31,8 +31,6 @@
disabled="1" type="object" class="fa fa-toggle-off o_auth_2fa_btn disabled" aria-label="Enable 2FA">
-
@@ -105,36 +103,4 @@
-
-
-
- users preference: Account Security
- res.users
-
- primary
-
-
-
-
-
-
- $0
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/addons/auth_totp_mail/__init__.py b/addons/auth_totp_mail/__init__.py
new file mode 100644
index 00000000000..dc5e6b693d1
--- /dev/null
+++ b/addons/auth_totp_mail/__init__.py
@@ -0,0 +1,4 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from . import models
diff --git a/addons/auth_totp_mail/__manifest__.py b/addons/auth_totp_mail/__manifest__.py
new file mode 100644
index 00000000000..05e1cbc2def
--- /dev/null
+++ b/addons/auth_totp_mail/__manifest__.py
@@ -0,0 +1,21 @@
+{
+ 'name': '2FA Invite mail',
+ 'description': """
+2FA Invite mail
+===============
+Allow the users to invite another user to use Two-Factor authentication
+by sending an email to the target user. This email redirect him to :
+- the users security settings if the user is internal.
+- the portal security settings page if the user is not internal.
+ """,
+ 'depends': ['auth_totp', 'mail'],
+ 'category': 'Extra Tools',
+ 'auto_install': True,
+ 'data': [
+ 'data/ir_action_data.xml',
+ 'data/mail_template_data.xml',
+ 'views/res_users_views.xml',
+ ],
+ 'assets': {},
+ 'license': 'LGPL-3',
+}
diff --git a/addons/auth_totp_mail/data/ir_action_data.xml b/addons/auth_totp_mail/data/ir_action_data.xml
new file mode 100644
index 00000000000..b9078e551e9
--- /dev/null
+++ b/addons/auth_totp_mail/data/ir_action_data.xml
@@ -0,0 +1,27 @@
+
+
+
+
+ Invite to use two-factor authentication
+
+
+ list
+ code
+
+ action = records.action_totp_invite()
+
+
+
+
+
+
+ Open two-factor authentication configuration
+
+ code
+
+user = env.user
+action = user.action_open_my_account_settings()
+
+
+
+
diff --git a/addons/auth_totp/data/mail_template_data.xml b/addons/auth_totp_mail/data/mail_template_data.xml
similarity index 100%
rename from addons/auth_totp/data/mail_template_data.xml
rename to addons/auth_totp_mail/data/mail_template_data.xml
diff --git a/addons/auth_totp_mail/models/__init__.py b/addons/auth_totp_mail/models/__init__.py
new file mode 100644
index 00000000000..74f3017f7e6
--- /dev/null
+++ b/addons/auth_totp_mail/models/__init__.py
@@ -0,0 +1,4 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from . import res_users
diff --git a/addons/auth_totp_mail/models/res_users.py b/addons/auth_totp_mail/models/res_users.py
new file mode 100644
index 00000000000..e83e21ecafe
--- /dev/null
+++ b/addons/auth_totp_mail/models/res_users.py
@@ -0,0 +1,44 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import _, models
+
+
+class Users(models.Model):
+ _inherit = 'res.users'
+
+ def action_open_my_account_settings(self):
+ action = {
+ "name": _("Account Security"),
+ "type": "ir.actions.act_window",
+ "res_model": "res.users",
+ "views": [[self.env.ref('auth_totp_mail.res_users_view_form').id, "form"]],
+ "res_id": self.id,
+ }
+ return action
+
+ def get_totp_invite_url(self):
+ return '/web#action=auth_totp_mail.action_activate_two_factor_authentication'
+
+ def action_totp_invite(self):
+ invite_template = self.env.ref('auth_totp_mail.mail_template_totp_invite')
+ users_to_invite = self.sudo().filtered(lambda user: not user.totp_secret)
+ for user in users_to_invite:
+ email_values = {
+ 'email_from': self.env.user.email_formatted,
+ 'author_id': self.env.user.partner_id.id,
+ }
+ invite_template.send_mail(user.id, force_send=True, email_values=email_values,
+ notif_layout='mail.mail_notification_light')
+
+ # Display a confirmation toaster
+ return {
+ 'type': 'ir.actions.client',
+ 'tag': 'display_notification',
+ 'params': {
+ 'type': 'info',
+ 'sticky': False,
+ 'message': _("Invitation to use two-factor authentication sent for the following user(s): %s",
+ ', '.join(users_to_invite.mapped('name'))),
+ }
+ }
diff --git a/addons/auth_totp_mail/views/res_users_views.xml b/addons/auth_totp_mail/views/res_users_views.xml
new file mode 100644
index 00000000000..1f60bd5c7b2
--- /dev/null
+++ b/addons/auth_totp_mail/views/res_users_views.xml
@@ -0,0 +1,46 @@
+
+
+
+ res.users.view.form.inherit.auth.totp.mail
+ res.users
+
+
+
+
+
+
+
+
+
+
+ res.users.view.form.auth.totp.mail
+ res.users
+
+ primary
+
+
+
+
+
+
+ $0
+
+
+
+
+
+
+
+
+
+
+
+
+
+