summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authordmonzonis <mod@odoo.com>2020-05-08 10:06:13 +0000
committerThibault Delavallée <tde@odoo.com>2020-05-27 12:47:16 +0000
commit5b20117495b908bde3877c02db3ada7249eb7993 (patch)
treea47335f8f789c3ceb044bad4896ffbcd9306c0a1 /addons
parentb110bd4cbef272f311680ce8cba39b727b2d6c42 (diff)
[FIX] mail: channel_get not finding channels correctly
The channel_get method from mail.channel was not retrieving existing channels between partners correctly in some cases, which caused some annoyances, like OdooBot creating a new channel/thread each time the admin user logs in to remind them about changing the default password, instead of using an existing conversation. This was caused because because the SQL query was filtering the channels by comparing the partner ids to the result of the ARRAY_AGG function, which sometimes contains duplicates. Task ID: 2233014 PR #49661
Diffstat (limited to 'addons')
-rw-r--r--addons/mail/models/mail_channel.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/addons/mail/models/mail_channel.py b/addons/mail/models/mail_channel.py
index 5d9d988d9dc..b6e11e4fdc3 100644
--- a/addons/mail/models/mail_channel.py
+++ b/addons/mail/models/mail_channel.py
@@ -633,14 +633,14 @@ class Channel(models.Model):
partners_to.append(self.env.user.partner_id.id)
# determine type according to the number of partner in the channel
self.env.cr.execute("""
- SELECT P.channel_id as channel_id
+ SELECT P.channel_id
FROM mail_channel C, mail_channel_partner P
WHERE P.channel_id = C.id
AND C.public LIKE 'private'
AND P.partner_id IN %s
- AND channel_type LIKE 'chat'
+ AND C.channel_type LIKE 'chat'
GROUP BY P.channel_id
- HAVING array_agg(P.partner_id ORDER BY P.partner_id) = %s
+ HAVING ARRAY_AGG(DISTINCT P.partner_id ORDER BY P.partner_id) = %s
""", (tuple(partners_to), sorted(list(partners_to)),))
result = self.env.cr.dictfetchall()
if result: