Allow filtering users to be notified by cron tasks

Closes #14432
This commit is contained in:
Cédric Krier committed 2025-12-16 17:28:32 +01:00
1 parent 7be632030d
commit f1fbd7abb3
2 files changed
+8 -4

No files matched your search

+1
View File
@@ -1,3 +1,4 @@
* Allow filtering users to be notified by cron tasks
Version 7.8.0 - 2025-12-15
--------------------------
+7 -4
View File
@@ -312,7 +312,7 @@ class Cron(DeactivableMixin, ModelSQL, ModelView):
@classmethod
def notify(
cls, icon, action_id, action_value,
message_id, n=None, **variables):
message_id, n=None, user_domain=None, **variables):
"Notify subscribed users to the current cron task"
pool = Pool()
User = pool.get('res.user')
@@ -325,9 +325,12 @@ class Cron(DeactivableMixin, ModelSQL, ModelView):
action_id = ModelData.get_id(action_id)
if action_value is not None and not isinstance(action_value, str):
action_value = json.dumps(action_value)
users = User.search([
('notifications', 'in', method),
])
domain = [
('notifications', 'in', method),
]
if user_domain is not None:
domain.append(user_domain)
users = User.search(domain)
for language, users in groupby(
users, key=lambda u: u.language):
language = language.code if language else None