summaryrefslogtreecommitdiff
path: root/addons/mail_bot
diff options
context:
space:
mode:
authorNicolas Seinlet <nse@openerp.com>2018-10-22 10:15:28 +0000
committerNicolas Seinlet <nse@openerp.com>2018-10-22 10:15:28 +0000
commit0e948f6f35d678917ac30dc2f53d6fb70ce8d246 (patch)
tree325026b055d0c857eeb8e9b716ece1e3dffa992c /addons/mail_bot
parent25e82a5c6837c6b55478222942038bbcb3a06a66 (diff)
[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
Diffstat (limited to 'addons/mail_bot')
-rw-r--r--addons/mail_bot/models/mail_channel.py11
1 files 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):