[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
This commit is contained in:
committed by
Thibault Delavallée
parent
b110bd4cbe
commit
5b20117495
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user