From 0e948f6f35d678917ac30dc2f53d6fb70ce8d246 Mon Sep 17 00:00:00 2001 From: Nicolas Seinlet Date: Mon, 22 Oct 2018 10:15:28 +0000 Subject: [PATCH] [FIX] mail_bot: call super and append result Instead of using an or which is a nightmare for PostgreSQL in this use case, call super and simply append odoobot to the result. closes odoo/odoo#28017 --- addons/mail_bot/models/mail_channel.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/addons/mail_bot/models/mail_channel.py b/addons/mail_bot/models/mail_channel.py index 490bd1048b6..3e2258902bf 100644 --- a/addons/mail_bot/models/mail_channel.py +++ b/addons/mail_bot/models/mail_channel.py @@ -14,14 +14,9 @@ class Channel(models.Model): @api.model def channel_fetch_listeners(self, uuid): """ Return the id, name and email of partners listening to the given channel """ - odoobot_id = self.env['ir.model.data'].xmlid_to_res_id("base.partner_root") - self._cr.execute(""" - SELECT P.id, P.name, P.email - FROM mail_channel_partner CP - INNER JOIN res_partner P ON CP.partner_id = P.id - INNER JOIN mail_channel C ON CP.channel_id = C.id - WHERE C.uuid = %s OR P.id = %s""", (uuid, odoobot_id,)) - return self._cr.dictfetchall() + result = super().channel_fetch_listeners(uuid) + odoobot = self.env.ref("base.partner_root").sudo() + return result + [{'id': odoobot.id, 'name': odoobot.name, 'email': odoobot.email}] @api.model def init_odoobot(self):