From d99b0e42596aa8eabe1a4dc14d729e2efc4f607d Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Mon, 21 Oct 2019 19:47:08 +0000 Subject: [PATCH] [FIX] im_livechat: performance issue: slow to open dashboard of livechat channels closes odoo/odoo#39154 X-original-commit: 6a08db92769da82023d25d04072027f8a54659b8 Signed-off-by: Nicolas Martinelli (nim) --- addons/im_livechat/models/im_livechat_channel.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/im_livechat/models/im_livechat_channel.py b/addons/im_livechat/models/im_livechat_channel.py index d6e23c282cd..45079a57f04 100644 --- a/addons/im_livechat/models/im_livechat_channel.py +++ b/addons/im_livechat/models/im_livechat_channel.py @@ -70,8 +70,10 @@ class ImLivechatChannel(models.Model): @api.depends('channel_ids') def _compute_nbr_channel(self): + data = self.env['mail.channel'].read_group([('livechat_channel_id', 'in', self._ids)], ['__count'], ['livechat_channel_id'], lazy=False) + channel_count = {x['livechat_channel_id'][0]: x['__count'] for x in data} for record in self: - record.nbr_channel = len(record.channel_ids) + record.nbr_channel = channel_count.get(record.id, 0) # -------------------------- # Action Methods