From c0dd1e4f91d6ff3ac5f8e6419e6f5a0459f449f5 Mon Sep 17 00:00:00 2001 From: Fabio Barbero Date: Thu, 21 Apr 2022 10:06:03 +0000 Subject: [PATCH] [FIX] gamification: stop notifying users on intermediate ranks Purpose ======= Avoid sending lost of emails for new ranks rank for each user when installing gamification module. Emails are now only sent outside of module installation. Task-2746929 X-original-commit: 5dc3b3ef794b78f18713b4bcf6254ab60d62eec4 Part-of: odoo/odoo#89463 --- addons/gamification/models/res_users.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/gamification/models/res_users.py b/addons/gamification/models/res_users.py index 02178090390..5f76b41e3fc 100644 --- a/addons/gamification/models/res_users.py +++ b/addons/gamification/models/res_users.py @@ -180,6 +180,10 @@ WHERE sub.user_id IN %%s""" % { """ Method that can be called on a batch of users with the same new rank """ + if self.env.context.get('install_mode', False): + # avoid sending emails in install mode (prevents spamming users when creating data ranks) + return + template = self.env.ref('gamification.mail_template_data_new_rank_reached', raise_if_not_found=False) if template: for u in self: