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

Module: Mail Activity Reminder

Entity: mail.activity

Compute Method: _compute_next_reminder

Inputs Method Outputs
now = fields.Datetime.now()
for activity in self:
            if activity.deadline < now:
                activity.next_reminder = None
                continue
            reminders = activity.activity_type_id._get_reminder_offsets()
            if not reminders:
                activity.next_reminder = None
                continue
            reminders.sort(reverse=True)
            tz = timezone(activity.user_id.sudo().tz or "UTC")
            last_reminder_local = (
                tz.localize(activity.last_reminder_local)
                if activity.last_reminder_local
                else None
            )
            local_deadline = tz.localize(
                datetime.combine(
                    activity.date_deadline,
                    time.min,  # Schedule reminder based of beginning of day
                )
            )
            for reminder in reminders:
                next_reminder_local = local_deadline - relativedelta(
                    days=reminder,
                )
                if not last_reminder_local or next_reminder_local > last_reminder_local:
                    break
            if last_reminder_local and next_reminder_local <= last_reminder_local:
                activity.next_reminder = None
                continue
            activity.next_reminder = next_reminder_local.astimezone(UTC).replace(
                tzinfo=None
            )

Back to entity