Skip to content

[ADD] hr_holidays_google_calendar: suppress Google/Outlook invitations on leave approval#64

Closed
mav-adhoc wants to merge 4 commits into
ingadhoc:19.0from
adhoc-dev:19.0-h-120192-mav
Closed

[ADD] hr_holidays_google_calendar: suppress Google/Outlook invitations on leave approval#64
mav-adhoc wants to merge 4 commits into
ingadhoc:19.0from
adhoc-dev:19.0-h-120192-mav

Conversation

@mav-adhoc

@mav-adhoc mav-adhoc commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

When a time off is approved, hr_holidays creates a calendar.event with no_mail_to_attendees=True (Odoo does not send emails itself), but calendar sync modules bypass this flag via their own notification mechanisms:

  • Google Calendar: google_sync._google_insert uses send_updates=True by default → Google sends a native calendar invitation to all attendees, even employees without an Odoo user (added via work_contact_id).
  • Microsoft Calendar: _microsoft_values includes attendees in the Graph API payload → Outlook sends invitation emails on its side.

Fix

Two auto_install glue modules that activate only when the respective calendar sync module is installed alongside hr_holidays. Both honour the existing no_mail_to_attendees=True flag that hr_holidays already sets, giving it priority over the calendar sync notification mechanism.

hr_holidays_google_calendar — overrides calendar.event._google_insert:

def _google_insert(self, google_service, values, timeout=TIMEOUT):
    if self.env.context.get("no_mail_to_attendees"):
        self = self.with_context(send_updates=False)
    return super()._google_insert(google_service, values, timeout=timeout)

hr_holidays_microsoft_calendar — overrides calendar.event._microsoft_values:

def _microsoft_values(self, fields_to_sync, initial_values=()):
    values = super()._microsoft_values(fields_to_sync, initial_values)
    if self.env.context.get("no_mail_to_attendees"):
        values.pop("attendees", None)
    return values

The context key no_mail_to_attendees is preserved through @after_commit (both sync modules capture self.env.context before deferring execution).

Test plan

  • Approve a time off for an employee whose approver has Google Calendar sync enabled.
    • Employee must not receive a Google Calendar invitation.
    • The calendar event must still appear in the approver's Google Calendar.
  • Approve a time off for an employee whose approver has Outlook sync enabled.
    • Employee must not receive an Outlook meeting invitation.
    • The calendar event must still appear in the approver's Outlook calendar.
  • Verify normal leave flow (approve, refuse, reset) is unaffected in both cases.

@roboadhoc

Copy link
Copy Markdown

Pull request status dashboard

…press calendar invitations on leave approval

When hr_holidays validates a leave it creates a calendar.event with
no_mail_to_attendees=True, but calendar sync modules (Google, Outlook)
bypass this flag via their own notification mechanisms.

- hr_holidays_google_calendar: overrides _google_insert to set
  send_updates=False when no_mail_to_attendees is in context, preventing
  Google from emailing attendees when pushing the event.
- hr_holidays_microsoft_calendar: overrides _microsoft_values to remove
  the attendees key from the Graph API payload when no_mail_to_attendees
  is in context, preventing Outlook from sending invitation emails.

Both modules are auto_install glue modules that activate only when the
respective calendar sync module is installed alongside hr_holidays.
@mav-adhoc mav-adhoc changed the title [FIX] hr_holidays_ux: suppress Google Calendar invitations on leave approval [FIX] hr_holidays: suppress Google/Outlook invitations on leave approval Jun 16, 2026
@mav-adhoc mav-adhoc changed the title [FIX] hr_holidays: suppress Google/Outlook invitations on leave approval [ADD] hr_holidays_google_calendar: suppress Google/Outlook invitations on leave approval Jun 16, 2026
@jcadhoc

jcadhoc commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

@roboadhoc r+ nobump rebase-ff

@roboadhoc

Copy link
Copy Markdown

Merge method set to rebase and fast-forward.

roboadhoc pushed a commit that referenced this pull request Jun 17, 2026
…pproval

Part-of: #64
Signed-off-by: Juan Carreras <jc@adhoc.com.ar>
roboadhoc pushed a commit that referenced this pull request Jun 17, 2026
…press calendar invitations on leave approval

When hr_holidays validates a leave it creates a calendar.event with
no_mail_to_attendees=True, but calendar sync modules (Google, Outlook)
bypass this flag via their own notification mechanisms.

- hr_holidays_google_calendar: overrides _google_insert to set
  send_updates=False when no_mail_to_attendees is in context, preventing
  Google from emailing attendees when pushing the event.
- hr_holidays_microsoft_calendar: overrides _microsoft_values to remove
  the attendees key from the Graph API payload when no_mail_to_attendees
  is in context, preventing Outlook from sending invitation emails.

Both modules are auto_install glue modules that activate only when the
respective calendar sync module is installed alongside hr_holidays.

Part-of: #64
Signed-off-by: Juan Carreras <jc@adhoc.com.ar>
roboadhoc pushed a commit that referenced this pull request Jun 17, 2026
… unit tests for no_mail_to_attendees fix

Part-of: #64
Signed-off-by: Juan Carreras <jc@adhoc.com.ar>
@roboadhoc roboadhoc closed this in 238adc1 Jun 17, 2026
@roboadhoc roboadhoc deleted the 19.0-h-120192-mav branch June 17, 2026 15:17
@roboadhoc roboadhoc added the 18.1 label Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants