19.0 vanilla

This commit is contained in:
Ernad Husremovic 2026-03-09 09:32:28 +01:00
parent 20ddc1b4a3
commit c0efcc53f5
1162 changed files with 125577 additions and 105287 deletions

View file

@ -7,7 +7,7 @@ from odoo import _, fields, models, api
from odoo.exceptions import UserError
class IrMailServer(models.Model):
class IrMail_Server(models.Model):
"""Represents an SMTP server, able to send outgoing emails, with SSL and TLS capabilities."""
_name = 'ir.mail_server'
@ -23,14 +23,14 @@ class IrMailServer(models.Model):
'Connect your Gmail 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 - gmail_servers)._compute_smtp_authentication_info()
super(IrMail_Server, self - gmail_servers)._compute_smtp_authentication_info()
@api.onchange('smtp_encryption')
def _onchange_encryption(self):
"""Do not change the SMTP configuration if it's a Gmail server
(e.g. the port which is already set)"""
if self.smtp_authentication != 'gmail':
super(IrMailServer, self)._onchange_encryption()
super()._onchange_encryption()
@api.onchange('smtp_authentication')
def _onchange_smtp_authentication_gmail(self):
@ -39,7 +39,6 @@ class IrMailServer(models.Model):
self.smtp_encryption = 'starttls'
self.smtp_port = 587
else:
self.google_gmail_authorization_code = False
self.google_gmail_refresh_token = False
self.google_gmail_access_token = False
self.google_gmail_access_token_expiration = False
@ -56,12 +55,12 @@ class IrMailServer(models.Model):
for server in gmail_servers:
if server.smtp_pass:
raise UserError(_(
'Please leave the password field empty for Gmail mail server %r. '
'Please leave the password field empty for Gmail mail server %s. '
'The OAuth process does not require it', server.name))
if server.smtp_encryption != 'starttls':
raise UserError(_(
'Incorrect Connection Security for Gmail mail server %r. '
'Incorrect Connection Security for Gmail mail server %s. '
'Please set it to "TLS (STARTTLS)".', server.name))
if not server.smtp_user:
@ -69,11 +68,11 @@ class IrMailServer(models.Model):
'Please fill the "Username" field with your Gmail username (your email address). '
'This should be the same account as the one used for the Gmail OAuthentication Token.'))
def _smtp_login(self, connection, smtp_user, smtp_password):
def _smtp_login__(self, connection, smtp_user, smtp_password): # noqa: PLW3201
if len(self) == 1 and self.smtp_authentication == 'gmail':
auth_string = self._generate_oauth2_string(smtp_user, self.google_gmail_refresh_token)
oauth_param = base64.b64encode(auth_string.encode()).decode()
connection.ehlo()
connection.docmd('AUTH', f'XOAUTH2 {oauth_param}')
else:
super(IrMailServer, self)._smtp_login(connection, smtp_user, smtp_password)
super()._smtp_login__(connection, smtp_user, smtp_password)