From 75280cf00e75cdd3e53a91d7265a1d5b9a0e2c2e Mon Sep 17 00:00:00 2001 From: Paul Morelle Date: Thu, 19 Nov 2020 16:30:21 +0000 Subject: [PATCH] [FIX] event: avoid too large prefetching of event.mail The prefetching engine wants to prefetch all the registrations to all the events of all the schedulers, which may make a lot of data. If the autocommit is on, then all this prefetched data is discarded at each loop. This commit limits the prefetching to each scheduler, so that we avoid prefetching the data unnecessarily. closes odoo/odoo#62052 X-original-commit: 904a46f28cb64e3bd51c40dc364b256d434d1c93 Signed-off-by: Olivier Dony (odo) Signed-off-by: Paul Morelle --- addons/event/models/event_mail.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/event/models/event_mail.py b/addons/event/models/event_mail.py index 8d5ea40fc1a..58fc24af9ed 100644 --- a/addons/event/models/event_mail.py +++ b/addons/event/models/event_mail.py @@ -169,7 +169,8 @@ You receive this email because you are: for scheduler in schedulers: try: with self.env.cr.savepoint(): - scheduler.execute() + # Prevent a mega prefetch of the registration ids of all the events of all the schedulers + self.browse(scheduler.id).execute() except Exception as e: _logger.exception(e) self.invalidate_cache()