summaryrefslogtreecommitdiff
path: root/addons/gamification/models
diff options
context:
space:
mode:
authorXavierDo <xdo@odoo.com>2019-04-12 11:43:36 +0000
committerThibault Delavallée <tde@odoo.com>2019-05-29 13:32:26 +0000
commit6f43977a4e2837cc8a2b47f3cab086f334c20978 (patch)
tree400bc1f39cb25640808b514638693b3153732aad /addons/gamification/models
parentc9d173a3e7645eef388a927466d564889d304cb6 (diff)
[REF] mail: improve message_post and message_notify API
Message post should always be called on a record (ensure_one). That way we ensure posting a message is always done in a record's context with right values computed (reply_to, followers, ...) Message_notify can be called on record or on mail_thread and must have partner_ids. It is based on the recently modified user_notification mechanism and allow to notify a partner on a record or just to push him a message (aka, not linked to a record). Small performance improvement * browse recipients instead of search in _notify_email_recipients; * todo in future optimizations: mayybe be improve by searching on ids and is_blacklist immediately; Related to task 1943901 Linked to PR #32404
Diffstat (limited to 'addons/gamification/models')
-rw-r--r--addons/gamification/models/challenge.py4
-rw-r--r--addons/gamification/models/goal.py3
2 files changed, 3 insertions, 4 deletions
diff --git a/addons/gamification/models/challenge.py b/addons/gamification/models/challenge.py
index 2c5c6c7e84d..c95e1f291d7 100644
--- a/addons/gamification/models/challenge.py
+++ b/addons/gamification/models/challenge.py
@@ -586,8 +586,8 @@ class Challenge(models.Model):
'gamification.challenge',
challenge.id)
- # send message only to users, not on the challenge
- self.env['gamification.challenge'].message_post(
+ # notify message only to users, do not post on the challenge
+ challenge.message_notify(
body=body_html,
partner_ids=[user.partner_id.id],
subtype='mail.mt_comment',
diff --git a/addons/gamification/models/goal.py b/addons/gamification/models/goal.py
index 506e34ceb83..81e8616b316 100644
--- a/addons/gamification/models/goal.py
+++ b/addons/gamification/models/goal.py
@@ -222,8 +222,7 @@ class Goal(models.Model):
.get_email_template(self.id)
body_html = self.env['mail.template'].with_context(template._context)\
._render_template(template.body_html, 'gamification.goal', self.id)
- # TDE NOTE: should be a notification (see with xdo)
- self.env['mail.thread'].message_post(
+ self.message_notify(
body=body_html,
partner_ids=[self.user_id.partner_id.id],
subtype='mail.mt_comment',