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

Module: Discuss

Entity: discuss.channel

Compute Method: _compute_channel_name_member_ids

View 19.0
Inputs Method Outputs
  • id
+ to_compute = self.filtered(
+             lambda c: c.channel_type in self._member_based_naming_channel_types()
+         )
+ (self - to_compute).channel_name_member_ids = False
+ if not to_compute:
+             return
+ self.env.cr.execute("""
+             SELECT channel.id, member.id
+               FROM discuss_channel channel
+       JOIN LATERAL
+                 (
+                    SELECT id
+                      FROM discuss_channel_member M
+                     WHERE M.channel_id = channel.id
+                  ORDER BY id
+                     LIMIT 3
+                 ) as member ON TRUE
+              WHERE channel.id IN %s
+         """, (tuple(to_compute.ids),))
+ channel_id_to_member_ids = defaultdict(list)
+ for channel_id, member_id in self.env.cr.fetchall():
+             channel_id_to_member_ids[channel_id].append(member_id)
+ for channel in self:
+             channel.channel_name_member_ids = channel_id_to_member_ids.get(channel.id)
  • channel_name_member_ids

Back to entity