Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: Live Chat

Entity: im_livechat.channel

Compute Method: _compute_nbr_channel

View 19.0 View 20.0
Inputs Method Outputs
  • id
- data = self.env['discuss.channel']._read_group([
-             ('livechat_channel_id', 'in', self.ids),
-         ], ['livechat_channel_id'], ['__count'])
- channel_count = {livechat_channel.id: count for livechat_channel, count in data}
+ count_by_channel = dict(
+             self.env["discuss.channel"]._read_group(
+                 [("livechat_channel_id", "in", self.ids), ("create_date", ">", "today -29d")],
+                 ["livechat_channel_id"],
+                 ["__count"],
+             ),
+         )
for record in self:
-             record.nbr_channel = channel_count.get(record.id, 0)
+             record.nbr_channel = count_by_channel.get(record, 0)
  • nbr_channel

Back to entity