Skip to content
Snippets Groups Projects
Unverified Commit a3509d28 authored by Damien Bouvy's avatar Damien Bouvy
Browse files

[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.
parent d98e5bb6
No related branches found
No related tags found
No related merge requests found
...@@ -31,13 +31,13 @@ class PublisherWarrantyContract(AbstractModel): ...@@ -31,13 +31,13 @@ class PublisherWarrantyContract(AbstractModel):
limit_date = datetime.datetime.now() limit_date = datetime.datetime.now()
limit_date = limit_date - datetime.timedelta(15) limit_date = limit_date - datetime.timedelta(15)
limit_date_str = limit_date.strftime(misc.DEFAULT_SERVER_DATETIME_FORMAT) limit_date_str = limit_date.strftime(misc.DEFAULT_SERVER_DATETIME_FORMAT)
nbr_users = Users.search_count([]) nbr_users = Users.search_count([('active', '=', True)])
nbr_active_users = Users.search_count([("login_date", ">=", limit_date_str)]) nbr_active_users = Users.search_count([("login_date", ">=", limit_date_str), ('active', '=', True)])
nbr_share_users = 0 nbr_share_users = 0
nbr_active_share_users = 0 nbr_active_share_users = 0
if "share" in Users._fields: if "share" in Users._fields:
nbr_share_users = Users.search_count([("share", "=", True)]) nbr_share_users = Users.search_count([("share", "=", True), ('active', '=', True)])
nbr_active_share_users = Users.search_count([("share", "=", True), ("login_date", ">=", limit_date_str)]) nbr_active_share_users = Users.search_count([("share", "=", True), ("login_date", ">=", limit_date_str), ('active', '=', True)])
user = self.env.user user = self.env.user
domain = [('application', '=', True), ('state', 'in', ['installed', 'to upgrade', 'to remove'])] domain = [('application', '=', True), ('state', 'in', ['installed', 'to upgrade', 'to remove'])]
apps = self.env['ir.module.module'].sudo().search_read(domain, ['name']) apps = self.env['ir.module.module'].sudo().search_read(domain, ['name'])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment