[FIX] mail: faster blacklist search

For the special case of is_blacklisted, and due to
the size of the tablers to handle, it's faster to
filter some records rather than searching the whole
res.partner table

closes odoo/odoo#28028
This commit is contained in:
Nicolas Seinlet
2018-10-22 12:45:17 +00:00
parent 273126ab34
commit 80cef9e8c5
+1 -1
View File
@@ -340,7 +340,7 @@ class Channel(models.Model):
@api.multi
def _notify_email_recipients(self, message, recipient_ids):
# Excluded Blacklisted
whitelist = self.env['res.partner'].sudo().search([('id', 'in', recipient_ids), ('is_blacklisted', '=', False)])
whitelist = self.env['res.partner'].sudo().search([('id', 'in', recipient_ids)]).filtered(lambda p: not p.is_blacklisted)
# real mailing list: multiple recipients (hidden by X-Forge-To)
if self.alias_domain and self.alias_name:
return {