diff --git a/addons/fetchmail/models/fetchmail.py b/addons/fetchmail/models/fetchmail.py index b477f2328e1..ea9c649dea3 100644 --- a/addons/fetchmail/models/fetchmail.py +++ b/addons/fetchmail/models/fetchmail.py @@ -43,10 +43,11 @@ class FetchmailServer(models.Model): server = fields.Char(string='Server Name', readonly=True, help="Hostname or IP of the mail server", states={'draft': [('readonly', False)]}) port = fields.Integer(readonly=True, states={'draft': [('readonly', False)]}) server_type = fields.Selection([ - ('pop', 'POP Server'), ('imap', 'IMAP Server'), + ('pop', 'POP Server'), ('local', 'Local Server'), ], string='Server Type', index=True, required=True, default='pop') + server_type_info = fields.Text('Server Type Info', compute='_compute_server_type_info') is_ssl = fields.Boolean('SSL/TLS', help="Connections are encrypted with SSL/TLS through a dedicated port (default: IMAPS=993, POP3S=995)") attach = fields.Boolean('Keep Attachments', help="Whether attachments should be downloaded. " "If not enabled, incoming emails will be stripped of any attachments before being processed", default=True) @@ -64,6 +65,14 @@ class FetchmailServer(models.Model): configuration = fields.Text('Configuration', readonly=True) script = fields.Char(readonly=True, default='/mail/static/scripts/odoo-mailgate.py') + @api.depends('server_type') + def _compute_server_type_info(self): + for server in self: + if server.server_type == 'local': + server.server_type_info = _('Use a local script to fetch your emails and create new records.') + else: + server.server_type_info = False + @api.onchange('server_type', 'is_ssl', 'object_id') def onchange_server_type(self): self.port = 0 diff --git a/addons/fetchmail/views/fetchmail_views.xml b/addons/fetchmail/views/fetchmail_views.xml index 59e65aad444..359faf5d06b 100644 --- a/addons/fetchmail/views/fetchmail_views.xml +++ b/addons/fetchmail/views/fetchmail_views.xml @@ -5,14 +5,14 @@ fetchmail.server.list fetchmail.server - + - - + - - + @@ -29,10 +29,20 @@ - - - - + + + + + + + + + + @@ -47,7 +57,8 @@ - + @@ -63,7 +74,7 @@ - + @@ -78,6 +89,7 @@ + diff --git a/addons/fetchmail_gmail/__init__.py b/addons/fetchmail_gmail/__init__.py deleted file mode 100644 index dc5e6b693d1..00000000000 --- a/addons/fetchmail_gmail/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from . import models diff --git a/addons/fetchmail_gmail/__manifest__.py b/addons/fetchmail_gmail/__manifest__.py deleted file mode 100644 index ec9db906501..00000000000 --- a/addons/fetchmail_gmail/__manifest__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -{ - "name": "Fetchmail Gmail", - "version": "1.1", - "category": "Hidden", - "description": "Google authentication for incoming mail server", - "depends": [ - "google_gmail", - "fetchmail", - ], - "data": ["views/fetchmail_server_views.xml"], - "auto_install": True, - "license": "LGPL-3", -} diff --git a/addons/fetchmail_gmail/i18n/fetchmail_gmail.pot b/addons/fetchmail_gmail/i18n/fetchmail_gmail.pot deleted file mode 100644 index e4f1f7af6a3..00000000000 --- a/addons/fetchmail_gmail/i18n/fetchmail_gmail.pot +++ /dev/null @@ -1,90 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * fetchmail_gmail -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server saas~15.2\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-02-11 14:34+0000\n" -"PO-Revision-Date: 2022-02-11 14:34+0000\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: fetchmail_gmail -#: model_terms:ir.ui.view,arch_db:fetchmail_gmail.fetchmail_server_view_form -msgid "" -"\n" -" Connect your Gmail account" -msgstr "" - -#. module: fetchmail_gmail -#: model_terms:ir.ui.view,arch_db:fetchmail_gmail.fetchmail_server_view_form -msgid "" -"\n" -" Edit Settings" -msgstr "" - -#. module: fetchmail_gmail -#: model_terms:ir.ui.view,arch_db:fetchmail_gmail.fetchmail_server_view_form -msgid "" -" \ No newline at end of file diff --git a/addons/google_gmail/static/src/scss/google_gmail.scss b/addons/google_gmail/static/src/scss/google_gmail.scss new file mode 100644 index 00000000000..1bc54662b5c --- /dev/null +++ b/addons/google_gmail/static/src/scss/google_gmail.scss @@ -0,0 +1,4 @@ +span.o_field_char[name="google_gmail_authorization_code"] { + max-width: 150px !important; + overflow: hidden; +} diff --git a/addons/fetchmail_gmail/views/fetchmail_server_views.xml b/addons/google_gmail/views/fetchmail_server_views.xml similarity index 77% rename from addons/fetchmail_gmail/views/fetchmail_server_views.xml rename to addons/google_gmail/views/fetchmail_server_views.xml index 259ebe57ee4..aae7e7a9202 100644 --- a/addons/fetchmail_gmail/views/fetchmail_server_views.xml +++ b/addons/google_gmail/views/fetchmail_server_views.xml @@ -9,8 +9,8 @@ -
-
+
Gmail Token Valid @@ -22,22 +22,18 @@ Connect your Gmail account - +
- - - {'required' : [('server_type', '!=', 'local'), ('server_type', '!=', 'gmail'), ('password', '!=', False)], 'invisible' : [('server_type', '=', 'gmail')]} - - diff --git a/addons/google_gmail/views/ir_mail_server_views.xml b/addons/google_gmail/views/ir_mail_server_views.xml index 910a77efa46..b8a25334623 100644 --- a/addons/google_gmail/views/ir_mail_server_views.xml +++ b/addons/google_gmail/views/ir_mail_server_views.xml @@ -8,8 +8,8 @@ -
-
+
Gmail Token Valid @@ -21,22 +21,23 @@ Connect your Gmail account - +
- - {'invisible' : [('smtp_authentication', '!=', 'login'), ('smtp_authentication', '!=', 'gmail')]} - - - {'invisible' : [('smtp_authentication', '=', 'gmail')]} + + + Read More + diff --git a/addons/google_gmail/views/res_config_settings_views.xml b/addons/google_gmail/views/res_config_settings_views.xml index 3a7a1bfcdac..d0d83760d49 100644 --- a/addons/google_gmail/views/res_config_settings_views.xml +++ b/addons/google_gmail/views/res_config_settings_views.xml @@ -8,12 +8,14 @@
-
-
diff --git a/addons/mail/models/res_config_settings.py b/addons/mail/models/res_config_settings.py index 04e6769c969..bfc67e9252e 100644 --- a/addons/mail/models/res_config_settings.py +++ b/addons/mail/models/res_config_settings.py @@ -16,6 +16,7 @@ class ResConfigSettings(models.TransientModel): 'Alias Domain', config_parameter='mail.catchall.domain', help="If you have setup a catch-all email domain redirected to the Odoo server, enter the domain name here.") module_google_gmail = fields.Boolean('Support Gmail Authentication') + module_microsoft_outlook = fields.Boolean('Support Outlook Authentication') restrict_template_rendering = fields.Boolean( 'Restrict Template Rendering', config_parameter='mail.restrict.template.rendering', diff --git a/addons/mail/views/res_config_settings_views.xml b/addons/mail/views/res_config_settings_views.xml index 513be01ce90..ebe37cbe8fb 100644 --- a/addons/mail/views/res_config_settings_views.xml +++ b/addons/mail/views/res_config_settings_views.xml @@ -36,13 +36,43 @@
Configure your own email servers
-
@@ -66,22 +96,6 @@
-
Custom ICE server list diff --git a/addons/microsoft_outlook/__manifest__.py b/addons/microsoft_outlook/__manifest__.py index b1070571605..1c6df5b6d2c 100644 --- a/addons/microsoft_outlook/__manifest__.py +++ b/addons/microsoft_outlook/__manifest__.py @@ -3,13 +3,15 @@ { "name": "Microsoft Outlook", - "version": "1.0", + "version": "1.1", "category": "Hidden", - "description": "Outlook support for outgoing mail servers", + "description": "Outlook support for incoming / outgoing mail servers", "depends": [ + "fetchmail", "mail", ], "data": [ + "views/fetchmail_server_views.xml", "views/ir_mail_server_views.xml", "views/res_config_settings_views.xml", "views/templates.xml", diff --git a/addons/microsoft_outlook/models/__init__.py b/addons/microsoft_outlook/models/__init__.py index 890e54b29c0..0d80b44a934 100644 --- a/addons/microsoft_outlook/models/__init__.py +++ b/addons/microsoft_outlook/models/__init__.py @@ -3,5 +3,6 @@ from . import microsoft_outlook_mixin +from . import fetchmail_server from . import ir_mail_server from . import res_config_settings diff --git a/addons/microsoft_outlook/models/fetchmail_server.py b/addons/microsoft_outlook/models/fetchmail_server.py new file mode 100644 index 00000000000..52df4eaf582 --- /dev/null +++ b/addons/microsoft_outlook/models/fetchmail_server.py @@ -0,0 +1,69 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import _, api, fields, models +from odoo.exceptions import UserError + + +class FetchmailServer(models.Model): + """Add the Outlook OAuth authentication on the incoming mail servers.""" + + _name = 'fetchmail.server' + _inherit = ['fetchmail.server', 'microsoft.outlook.mixin'] + + _OUTLOOK_SCOPE = 'https://outlook.office.com/IMAP.AccessAsUser.All' + + server_type = fields.Selection(selection_add=[('outlook', 'Outlook OAuth Authentication')], ondelete={'outlook': 'set default'}) + + def _compute_server_type_info(self): + outlook_servers = self.filtered(lambda server: server.server_type == 'outlook') + outlook_servers.server_type_info = _( + 'Connect your personal Outlook account using OAuth. \n' + 'You will be redirected to the Outlook login page to accept ' + 'the permissions.') + super(FetchmailServer, self - outlook_servers)._compute_server_type_info() + + @api.depends('server_type') + def _compute_is_microsoft_outlook_configured(self): + outlook_servers = self.filtered(lambda server: server.server_type == 'outlook') + (self - outlook_servers).is_microsoft_outlook_configured = False + super(FetchmailServer, outlook_servers)._compute_is_microsoft_outlook_configured() + + @api.constrains('server_type', 'is_ssl') + def _check_use_microsoft_outlook_service(self): + for server in self: + if server.server_type == 'outlook' and not server.is_ssl: + raise UserError(_('SSL is required for the server %r.', server.name)) + + @api.onchange('server_type') + def onchange_server_type(self): + """Set the default configuration for a IMAP Outlook server.""" + if self.server_type == 'outlook': + self.server = 'imap.outlook.com' + self.is_ssl = True + self.port = 993 + else: + self.microsoft_outlook_refresh_token = False + self.microsoft_outlook_access_token = False + self.microsoft_outlook_access_token_expiration = False + super(FetchmailServer, self).onchange_server_type() + + def _imap_login(self, connection): + """Authenticate the IMAP connection. + + If the mail server is Outlook, we use the OAuth2 authentication protocol. + """ + self.ensure_one() + if self.server_type == 'outlook': + auth_string = self._generate_outlook_oauth2_string(self.user) + connection.authenticate('XOAUTH2', lambda x: auth_string) + connection.select('INBOX') + else: + super()._imap_login(connection) + + def _get_connection_type(self): + """Return which connection must be used for this mail server (IMAP or POP). + The Outlook mail server used an IMAP connection. + """ + self.ensure_one() + return 'imap' if self.server_type == 'outlook' else super()._get_connection_type() diff --git a/addons/microsoft_outlook/models/ir_mail_server.py b/addons/microsoft_outlook/models/ir_mail_server.py index c01ecf9ab44..f28f7fbd08a 100644 --- a/addons/microsoft_outlook/models/ir_mail_server.py +++ b/addons/microsoft_outlook/models/ir_mail_server.py @@ -3,7 +3,7 @@ import base64 -from odoo import _, api, models +from odoo import _, api, fields, models from odoo.exceptions import UserError @@ -15,12 +15,28 @@ class IrMailServer(models.Model): _OUTLOOK_SCOPE = 'https://outlook.office.com/SMTP.Send' - @api.constrains('use_microsoft_outlook_service', 'smtp_pass', 'smtp_encryption') - def _check_use_microsoft_outlook_service(self): - for server in self: - if not server.use_microsoft_outlook_service: - continue + smtp_authentication = fields.Selection( + selection_add=[('outlook', 'Outlook OAuth Authentication')], + ondelete={'outlook': 'set default'}) + @api.depends('smtp_authentication') + def _compute_is_microsoft_outlook_configured(self): + outlook_servers = self.filtered(lambda server: server.smtp_authentication == 'outlook') + (self - outlook_servers).is_microsoft_outlook_configured = False + super(IrMailServer, outlook_servers)._compute_is_microsoft_outlook_configured() + + def _compute_smtp_authentication_info(self): + outlook_servers = self.filtered(lambda server: server.smtp_authentication == 'outlook') + outlook_servers.smtp_authentication_info = _( + 'Connect your Outlook account with the OAuth Authentication process. \n' + 'By default, only a user with a matching email address will be able to use this server. ' + 'To extend its use, you should set a "mail.default.from" system parameter.') + super(IrMailServer, self - outlook_servers)._compute_smtp_authentication_info() + + @api.constrains('smtp_authentication', 'smtp_pass', 'smtp_encryption', 'from_filter', 'smtp_user') + def _check_use_microsoft_outlook_service(self): + outlook_servers = self.filtered(lambda server: server.smtp_authentication == 'outlook') + for server in outlook_servers: if server.smtp_pass: raise UserError(_( 'Please leave the password field empty for Outlook mail server %r. ' @@ -31,17 +47,22 @@ class IrMailServer(models.Model): 'Incorrect Connection Security for Outlook mail server %r. ' 'Please set it to "TLS (STARTTLS)".', server.name)) + if server.from_filter != server.smtp_user: + raise UserError(_( + 'This server %r can only be used for your personal email address. ' + 'Please fill the "from_filter" field with %r.', server.name, server.smtp_user)) + @api.onchange('smtp_encryption') def _onchange_encryption(self): """Do not change the SMTP configuration if it's a Outlook server (e.g. the port which is already set)""" - if not self.use_microsoft_outlook_service: + if self.smtp_authentication != 'outlook': super()._onchange_encryption() - @api.onchange('use_microsoft_outlook_service') - def _onchange_use_microsoft_outlook_service(self): - if self.use_microsoft_outlook_service: + @api.onchange('smtp_authentication') + def _onchange_smtp_authentication_outlook(self): + if self.smtp_authentication == 'outlook': self.smtp_host = 'smtp.outlook.com' self.smtp_encryption = 'starttls' self.smtp_port = 587 @@ -50,11 +71,17 @@ class IrMailServer(models.Model): self.microsoft_outlook_access_token = False self.microsoft_outlook_access_token_expiration = False + @api.onchange('smtp_user', 'smtp_authentication') + def _on_change_smtp_user_outlook(self): + """The Outlook mail servers can only be used for the user personal email address.""" + if self.smtp_authentication == 'outlook': + self.from_filter = self.smtp_user + def _smtp_login(self, connection, smtp_user, smtp_password): - if len(self) == 1 and self.use_microsoft_outlook_service: + if len(self) == 1 and self.smtp_authentication == 'outlook': auth_string = self._generate_outlook_oauth2_string(smtp_user) oauth_param = base64.b64encode(auth_string.encode()).decode() connection.ehlo() - connection.docmd('AUTH', 'XOAUTH2 %s' % oauth_param) + connection.docmd('AUTH', f'XOAUTH2 {oauth_param}') else: super()._smtp_login(connection, smtp_user, smtp_password) diff --git a/addons/microsoft_outlook/models/microsoft_outlook_mixin.py b/addons/microsoft_outlook/models/microsoft_outlook_mixin.py index 1e1fd397164..b74afa76e77 100644 --- a/addons/microsoft_outlook/models/microsoft_outlook_mixin.py +++ b/addons/microsoft_outlook/models/microsoft_outlook_mixin.py @@ -23,7 +23,6 @@ class MicrosoftOutlookMixin(models.AbstractModel): _OUTLOOK_SCOPE = None _OUTLOOK_ENDPOINT = 'https://login.microsoftonline.com/common/oauth2/v2.0/' - use_microsoft_outlook_service = fields.Boolean('Outlook Authentication') is_microsoft_outlook_configured = fields.Boolean('Is Outlook Credential Configured', compute='_compute_is_microsoft_outlook_configured') microsoft_outlook_refresh_token = fields.Char(string='Outlook Refresh Token', @@ -35,25 +34,25 @@ class MicrosoftOutlookMixin(models.AbstractModel): microsoft_outlook_uri = fields.Char(compute='_compute_outlook_uri', string='Authentication URI', help='The URL to generate the authorization code from Outlook', groups='base.group_system') - @api.depends('use_microsoft_outlook_service') def _compute_is_microsoft_outlook_configured(self): Config = self.env['ir.config_parameter'].sudo() microsoft_outlook_client_id = Config.get_param('microsoft_outlook_client_id') microsoft_outlook_client_secret = Config.get_param('microsoft_outlook_client_secret') self.is_microsoft_outlook_configured = microsoft_outlook_client_id and microsoft_outlook_client_secret - @api.depends('use_microsoft_outlook_service') + @api.depends('is_microsoft_outlook_configured') def _compute_outlook_uri(self): Config = self.env['ir.config_parameter'].sudo() base_url = self.get_base_url() microsoft_outlook_client_id = Config.get_param('microsoft_outlook_client_id') + OUTLOOK_ENDPOINT = Config.get_param('microsoft.outlook.endpoint', self._OUTLOOK_ENDPOINT) for record in self: - if not record.id or not record.use_microsoft_outlook_service or not record.is_microsoft_outlook_configured: + if not record.id or not record.is_microsoft_outlook_configured: record.microsoft_outlook_uri = False continue - record.microsoft_outlook_uri = url_join(self._OUTLOOK_ENDPOINT, 'authorize?%s' % url_encode({ + record.microsoft_outlook_uri = url_join(OUTLOOK_ENDPOINT, 'authorize?%s' % url_encode({ 'client_id': microsoft_outlook_client_id, 'response_type': 'code', 'redirect_uri': url_join(base_url, '/microsoft_outlook/confirm'), @@ -79,7 +78,7 @@ class MicrosoftOutlookMixin(models.AbstractModel): if not self.env.user.has_group('base.group_system'): raise AccessError(_('Only the administrator can link an Outlook mail server.')) - if not self.use_microsoft_outlook_service or not self.is_microsoft_outlook_configured: + if not self.is_microsoft_outlook_configured: raise UserError(_('Please configure your Outlook credentials.')) return { @@ -124,9 +123,10 @@ class MicrosoftOutlookMixin(models.AbstractModel): base_url = self.get_base_url() microsoft_outlook_client_id = Config.get_param('microsoft_outlook_client_id') microsoft_outlook_client_secret = Config.get_param('microsoft_outlook_client_secret') + OUTLOOK_ENDPOINT = Config.get_param('microsoft.outlook.endpoint', self._OUTLOOK_ENDPOINT) response = requests.post( - url_join(self._OUTLOOK_ENDPOINT, 'token'), + url_join(OUTLOOK_ENDPOINT, 'token'), data={ 'client_id': microsoft_outlook_client_id, 'client_secret': microsoft_outlook_client_secret, @@ -159,7 +159,7 @@ class MicrosoftOutlookMixin(models.AbstractModel): or not self.microsoft_outlook_access_token_expiration \ or self.microsoft_outlook_access_token_expiration < now_timestamp: if not self.microsoft_outlook_refresh_token: - raise UserError(_('Please login your Outlook mail server before using it.')) + raise UserError(_('Please connect with your Outlook account before using it.')) ( self.microsoft_outlook_access_token, self.microsoft_outlook_access_token_expiration, diff --git a/addons/microsoft_outlook/static/description/icon.png b/addons/microsoft_outlook/static/description/icon.png new file mode 100644 index 00000000000..6c454d3f896 Binary files /dev/null and b/addons/microsoft_outlook/static/description/icon.png differ diff --git a/addons/microsoft_outlook/static/description/icon.svg b/addons/microsoft_outlook/static/description/icon.svg new file mode 100644 index 00000000000..9408317cf0e --- /dev/null +++ b/addons/microsoft_outlook/static/description/icon.svg @@ -0,0 +1,51 @@ + \ No newline at end of file diff --git a/addons/fetchmail_outlook/tests/__init__.py b/addons/microsoft_outlook/tests/__init__.py similarity index 100% rename from addons/fetchmail_outlook/tests/__init__.py rename to addons/microsoft_outlook/tests/__init__.py diff --git a/addons/fetchmail_outlook/tests/test_fetchmail_outlook.py b/addons/microsoft_outlook/tests/test_fetchmail_outlook.py similarity index 76% rename from addons/fetchmail_outlook/tests/test_fetchmail_outlook.py rename to addons/microsoft_outlook/tests/test_fetchmail_outlook.py index 8cc07d1764d..143f379a598 100644 --- a/addons/fetchmail_outlook/tests/test_fetchmail_outlook.py +++ b/addons/microsoft_outlook/tests/test_fetchmail_outlook.py @@ -21,12 +21,11 @@ class TestFetchmailOutlook(TransactionCase): mail_server = self.env['fetchmail.server'].create({ 'name': 'Test server', - 'use_microsoft_outlook_service': True, + 'server_type': 'outlook', 'user': 'test@example.com', 'microsoft_outlook_access_token': 'test_access_token', 'microsoft_outlook_access_token_expiration': time.time() + 1000000, 'password': '', - 'server_type': 'imap', 'is_ssl': True, }) @@ -45,15 +44,6 @@ class TestFetchmailOutlook(TransactionCase): with self.assertRaises(UserError, msg='Should ensure that the password is empty'): self.env['fetchmail.server'].create({ 'name': 'Test server', - 'use_microsoft_outlook_service': True, + 'server_type': 'outlook', 'password': 'test', - 'server_type': 'imap', - }) - - with self.assertRaises(UserError, msg='Should ensure that the server type is IMAP'): - self.env['fetchmail.server'].create({ - 'name': 'Test server', - 'use_microsoft_outlook_service': True, - 'password': '', - 'server_type': 'pop', }) diff --git a/addons/fetchmail_outlook/views/fetchmail_server_views.xml b/addons/microsoft_outlook/views/fetchmail_server_views.xml similarity index 58% rename from addons/fetchmail_outlook/views/fetchmail_server_views.xml rename to addons/microsoft_outlook/views/fetchmail_server_views.xml index 30d432d74e0..a572fd3e448 100644 --- a/addons/fetchmail_outlook/views/fetchmail_server_views.xml +++ b/addons/microsoft_outlook/views/fetchmail_server_views.xml @@ -6,42 +6,36 @@ 1000 - - - -
-
- + Outlook Token Valid - +
- - {} -
diff --git a/addons/microsoft_outlook/views/ir_mail_server_views.xml b/addons/microsoft_outlook/views/ir_mail_server_views.xml index 8870b9419e1..5fd7c5db638 100644 --- a/addons/microsoft_outlook/views/ir_mail_server_views.xml +++ b/addons/microsoft_outlook/views/ir_mail_server_views.xml @@ -5,38 +5,42 @@ ir.mail_server - - - -
-
- + Outlook Token Valid - +
+ +
+ Read More + + diff --git a/addons/microsoft_outlook/views/res_config_settings_views.xml b/addons/microsoft_outlook/views/res_config_settings_views.xml index e1adf2dc6d8..b2ad3e606e3 100644 --- a/addons/microsoft_outlook/views/res_config_settings_views.xml +++ b/addons/microsoft_outlook/views/res_config_settings_views.xml @@ -6,27 +6,18 @@ res.config.settings -
-
-
- Outlook Credentials -
- Send and receive email with your Outlook account. -
-
-
-
-
-
-
-
+
+
+
+
+
diff --git a/odoo/addons/base/models/ir_mail_server.py b/odoo/addons/base/models/ir_mail_server.py index 39fddc7f733..de7ea18eebd 100644 --- a/odoo/addons/base/models/ir_mail_server.py +++ b/odoo/addons/base/models/ir_mail_server.py @@ -95,6 +95,7 @@ class IrMailServer(models.Model): smtp_host = fields.Char(string='SMTP Server', required=True, help="Hostname or IP of SMTP server") smtp_port = fields.Integer(string='SMTP Port', required=True, default=25, help="SMTP Port. Usually 465 for SSL, and 25 or 587 for other cases.") smtp_authentication = fields.Selection([('login', 'Username'), ('certificate', 'SSL Certificate')], string='Authenticate with', required=True, default='login') + smtp_authentication_info = fields.Text('Authentication Info', compute='_compute_smtp_authentication_info') smtp_user = fields.Char(string='Username', help="Optional username for SMTP authentication", groups='base.group_system') smtp_pass = fields.Char(string='Password', help="Optional password for SMTP authentication", groups='base.group_system') smtp_encryption = fields.Selection([('none', 'None'), @@ -118,6 +119,21 @@ class IrMailServer(models.Model): "is used. Default priority is 10 (smaller number = higher priority)") active = fields.Boolean(default=True) + @api.depends('smtp_authentication') + def _compute_smtp_authentication_info(self): + for server in self: + if server.smtp_authentication == 'login': + server.smtp_authentication_info = _( + 'Connect to your server through your usual username and password. \n' + 'This is the most basic SMTP authentication process and ' + 'may not be accepted by all providers. \n') + elif server.smtp_authentication == 'certificate': + server.smtp_authentication_info = _( + 'Authenticate by using SSL certificates, belonging to your domain name. \n' + 'SSL certificates allow you to authenticate your mail server for the entire domain name.') + else: + server.smtp_authentication = False + @api.constrains('smtp_ssl_certificate', 'smtp_ssl_private_key') def _check_smtp_ssl_files(self): """We must provided both files or none.""" diff --git a/odoo/addons/base/views/ir_mail_server_views.xml b/odoo/addons/base/views/ir_mail_server_views.xml index a8eaf982b09..553486cdd20 100644 --- a/odoo/addons/base/views/ir_mail_server_views.xml +++ b/odoo/addons/base/views/ir_mail_server_views.xml @@ -10,27 +10,47 @@ name="test_smtp_connection" class="btn-primary"/> - - - - - + + + + + + + + + + - + - - - - - - - - - + + + + + + + + + + + + + + + + + + + +