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

Module: Event Sessions

Entity: event.session

Compute Method: _compute_event_mail_ids

Inputs Method Outputs
"""Compute event mail ids from its parent event

        The email schedulers for sessions are used to track their independent states,
        but the management is done directly from the parent event.event.

        This method takes care of synchronizing the session's schedulers with those
        of their parent events.
        """
for rec in self:
            existing_schedulers = rec.event_mail_ids.scheduler_id
            event_schedulers = rec.event_id.event_mail_ids
            # Unlink the ones no-longer in sync
            to_unlink = rec.event_mail_ids.filtered(
                lambda r, event_schedulers=event_schedulers: r.scheduler_id
                not in event_schedulers
            )
            if to_unlink:
                rec.event_mail_ids = [
                    fields.Command.unlink(scheduler.id) for scheduler in to_unlink
                ]
            # Create missing ones
            to_create = event_schedulers - existing_schedulers
            if to_create:
                rec.event_mail_ids = [
                    fields.Command.create(
                        scheduler._prepare_session_mail_scheduler_vals(rec)
                    )
                    for scheduler in to_create
                ]
                # Force recomputation of scheduled date
                rec.event_mail_ids._compute_scheduled_date()

Back to entity