[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.
This commit is contained in:
@@ -31,13 +31,13 @@ class PublisherWarrantyContract(AbstractModel):
|
||||
limit_date = datetime.datetime.now()
|
||||
limit_date = limit_date - datetime.timedelta(15)
|
||||
limit_date_str = limit_date.strftime(misc.DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
nbr_users = Users.search_count([])
|
||||
nbr_active_users = Users.search_count([("login_date", ">=", limit_date_str)])
|
||||
nbr_users = Users.search_count([('active', '=', True)])
|
||||
nbr_active_users = Users.search_count([("login_date", ">=", limit_date_str), ('active', '=', True)])
|
||||
nbr_share_users = 0
|
||||
nbr_active_share_users = 0
|
||||
if "share" in Users._fields:
|
||||
nbr_share_users = Users.search_count([("share", "=", True)])
|
||||
nbr_active_share_users = Users.search_count([("share", "=", True), ("login_date", ">=", limit_date_str)])
|
||||
nbr_share_users = Users.search_count([("share", "=", True), ('active', '=', True)])
|
||||
nbr_active_share_users = Users.search_count([("share", "=", True), ("login_date", ">=", limit_date_str), ('active', '=', True)])
|
||||
user = self.env.user
|
||||
domain = [('application', '=', True), ('state', 'in', ['installed', 'to upgrade', 'to remove'])]
|
||||
apps = self.env['ir.module.module'].sudo().search_read(domain, ['name'])
|
||||
|
||||
Reference in New Issue
Block a user