[FIX] mass_mailing_list_dynamic: list sync on send

- We change the method to hook on (it wasn't correctly overriden anyway)
to ensure the list is resynced even if no recipients are left. For
example: we create a dynamic list with a domain expecting it to sync in
the first mass_mailing. It wouldn't sync as Odoo dismisses the mailing
considering no recipients are left thus it wouldn't get into the
`send_mail` method.
pull/571/head
david 2020-07-16 11:22:26 +02:00
parent b7bcfaf84a
commit b3cfd62848
1 changed files with 5 additions and 3 deletions

View File

@ -7,7 +7,9 @@ from odoo import models
class MassMailing(models.Model): class MassMailing(models.Model):
_inherit = "mail.mass_mailing" _inherit = "mail.mass_mailing"
def send_mail(self): def get_remaining_recipients(self):
"""Sync dynamic lists before sending mailings to them.""" """When evaluating remaining recipients we must resync the list in
advance to avoid missing recipients due to domain change or new
partners fitting into the conditions"""
self.contact_list_ids.action_sync() self.contact_list_ids.action_sync()
return super().send_mail() return super().get_remaining_recipients()