[FIX] base: make ir_mail_server ordering deterministic
This may have an impact when trying to find an outgoing mail server based on from and filter, as first match wins when checking matching filter on a bunch of mail servers. Prepares Task-36879 (Mail: Support Multi Domains Aliases) Part-of: odoo/odoo#76734
This commit is contained in:
@@ -494,7 +494,7 @@ class MailMail(models.Model):
|
||||
|
||||
# Then find the mail server for each email_from and group the <mail.mail>
|
||||
# per mail_server_id and smtp_from
|
||||
mail_servers = self.env['ir.mail_server'].sudo().search([], order='sequence')
|
||||
mail_servers = self.env['ir.mail_server'].sudo().search([], order='sequence, id')
|
||||
group_per_smtp_from = defaultdict(list)
|
||||
for (mail_server_id, email_from), mail_ids in group_per_email_from.items():
|
||||
if not mail_server_id:
|
||||
|
||||
@@ -87,7 +87,7 @@ class IrMailServer(models.Model):
|
||||
"""Represents an SMTP server, able to send outgoing emails, with SSL and TLS capabilities."""
|
||||
_name = "ir.mail_server"
|
||||
_description = 'Mail Server'
|
||||
_order = 'sequence'
|
||||
_order = 'sequence, id'
|
||||
|
||||
NO_VALID_RECIPIENT = ("At least one valid recipient address should be "
|
||||
"specified for outgoing emails (To/Cc/Bcc)")
|
||||
|
||||
@@ -430,18 +430,22 @@ class MockSmtplibCase:
|
||||
{
|
||||
'name': 'Domain based server',
|
||||
'from_filter': 'test.mycompany.com',
|
||||
'sequence': 0,
|
||||
** ir_mail_server_values,
|
||||
}, {
|
||||
'name': 'User specific server',
|
||||
'from_filter': 'specific_user@test.mycompany.com',
|
||||
'sequence': 1,
|
||||
** ir_mail_server_values,
|
||||
}, {
|
||||
'name': 'Server Notifications',
|
||||
'from_filter': 'notifications.test@test.mycompany.com',
|
||||
'sequence': 2,
|
||||
** ir_mail_server_values,
|
||||
}, {
|
||||
'name': 'Server No From Filter',
|
||||
'from_filter': False,
|
||||
'sequence': 3,
|
||||
** ir_mail_server_values,
|
||||
},
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user