Skip to content

Commit a3509d2

Browse files
committed
[FIX] mail: use explicit 'active' domain for user count in ping
Before the migration to the new API of this code, the context was not propagated to the update_notification call. This is now the case, which is unfortunate since the context of the cron action has an 'active_test'=False key, which causes the ping to count user differently when the cron is triggered from the form view. This commit adds explicit ('active','=',True) domain to ensure we only count active users when pinging.
1 parent d98e5bb commit a3509d2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

addons/mail/models/update.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ def _get_message(self):
3131
limit_date = datetime.datetime.now()
3232
limit_date = limit_date - datetime.timedelta(15)
3333
limit_date_str = limit_date.strftime(misc.DEFAULT_SERVER_DATETIME_FORMAT)
34-
nbr_users = Users.search_count([])
35-
nbr_active_users = Users.search_count([("login_date", ">=", limit_date_str)])
34+
nbr_users = Users.search_count([('active', '=', True)])
35+
nbr_active_users = Users.search_count([("login_date", ">=", limit_date_str), ('active', '=', True)])
3636
nbr_share_users = 0
3737
nbr_active_share_users = 0
3838
if "share" in Users._fields:
39-
nbr_share_users = Users.search_count([("share", "=", True)])
40-
nbr_active_share_users = Users.search_count([("share", "=", True), ("login_date", ">=", limit_date_str)])
39+
nbr_share_users = Users.search_count([("share", "=", True), ('active', '=', True)])
40+
nbr_active_share_users = Users.search_count([("share", "=", True), ("login_date", ">=", limit_date_str), ('active', '=', True)])
4141
user = self.env.user
4242
domain = [('application', '=', True), ('state', 'in', ['installed', 'to upgrade', 'to remove'])]
4343
apps = self.env['ir.module.module'].sudo().search_read(domain, ['name'])

0 commit comments

Comments
 (0)