From a58ffb9e78e3ee7cbe601207747c06eba851d7bf Mon Sep 17 00:00:00 2001 From: len-odoo Date: Thu, 5 Jul 2018 13:54:08 +0200 Subject: [PATCH] [FIX] mail: use ids parameter in the process_mail_queue method If the parameter ids is given to the process_mail_queue method, it is supposed to only process the ids it was given, not all mails. Commit https://github.com/odoo/odoo/commit/4b122ad41d873febe288ab1f8c6cdc078ca2a479 replaced ids by self.ids, and thus default filter was always applied. fix suggested by @suganthikarunanithi, Sodexis team opw 1860484 --- addons/mail/models/mail_mail.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/addons/mail/models/mail_mail.py b/addons/mail/models/mail_mail.py index e723f71bdc6..18267adb6d5 100644 --- a/addons/mail/models/mail_mail.py +++ b/addons/mail/models/mail_mail.py @@ -104,16 +104,19 @@ class MailMail(models.Model): messages to send (by default all 'outgoing' messages are sent). """ - if not self.ids: - filters = ['&', - ('state', '=', 'outgoing'), - '|', - ('scheduled_date', '<', datetime.datetime.now()), - ('scheduled_date', '=', False)] - if 'filters' in self._context: - filters.extend(self._context['filters']) - # TODO: make limit configurable - ids = self.search(filters, limit=10000).ids + filters = ['&', + ('state', '=', 'outgoing'), + '|', + ('scheduled_date', '<', datetime.datetime.now()), + ('scheduled_date', '=', False)] + if 'filters' in self._context: + filters.extend(self._context['filters']) + # TODO: make limit configurable + filtered_ids = self.search(filters, limit=10000).ids + if not ids: + ids = filtered_ids + else: + ids = list(set(filtered_ids) & set(ids)) res = None try: # auto-commit except in testing mode