Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/OCA/calendar/llms.txt

Use this file to discover all available pages before exploring further.

The calendar_public_holiday module introduces two persistent models and one transient wizard that together manage country- and state-scoped public holiday sets. A holiday set (calendar.public.holiday) groups individual holiday lines (calendar.public.holiday.line) under a single calendar year and optional country. Every line automatically creates and keeps in sync a calendar.event so that public holidays are visible in the standard Odoo calendar. The next-year wizard (calendar.public.holiday.next.year) copies an existing set forward to a new year in bulk.

calendar.public.holiday

Technical name: calendar.public.holiday
Description: Calendar Public Holiday
Default ordering: year desc
This model acts as the container for a set of public holidays. The combination of year and country_id must be unique across the database.

Fields

year
Integer
required
Calendar year for this holiday set. Defaults to the current year at creation time (fields.Date.context_today(self).year).
country_id
Many2one → res.country
Optional country scope. When set, only partners whose country_id matches will see these holidays when querying get_holidays_list(). Leave empty for a country-agnostic global set.
line_ids
One2many → calendar.public.holiday.line
The individual holiday entries that belong to this set. Related field public_holiday_id on the line side.
display_name
Char (computed)
Human-readable label. Computed from country_id:
  • With country: "YYYY (Country Name)" — e.g. "2025 (Belgium)"
  • Without country: "YYYY" — e.g. "2025"

Constraints

A database-level constraint enforced by _check_year() prevents creating two holiday sets with the same (year, country_id) pair. Attempting to do so raises a ValidationError.

Methods

get_holidays_list(year, start_dt, end_dt, partner_id)

@api.model
@api.returns("calendar.public.holiday.line")
def get_holidays_list(self, year=None, start_dt=None, end_dt=None, partner_id=None):
Returns a recordset of calendar.public.holiday.line filtered to the requested period and partner context.
ParameterTypeDescription
yearintCalendar year to query. Required when start_dt/end_dt are omitted.
start_dtdateStart of the date range. When provided together with end_dt, year is inferred from the range.
end_dtdateEnd of the date range (inclusive).
partner_idintDatabase ID of a res.partner. When supplied, results are filtered by the partner’s country_id and state_id.
The method first finds matching calendar.public.holiday records for the year(s) covered by the range, then calls _get_domain_states_filter() to further restrict lines to those that are either state-agnostic or match the partner’s province/state.

is_public_holiday(selected_date, partner_id)

@api.model
def is_public_holiday(self, selected_date, partner_id=None):
Convenience wrapper. Returns True if selected_date (a datetime.date object) falls on a public holiday for the given partner, False otherwise.

_get_domain_states_filter(pholidays, start_dt, end_dt, partner_id) (internal)

Builds the ORM domain used by get_holidays_list() to filter holiday lines by date range and state/region. When the partner has a state_id, the domain uses an OR clause to include lines that either match that state or have no state restriction. When the partner has no state, only state-agnostic lines (state_ids = False) are returned.
This method is called internally and is not part of the public API. Override it in a custom module to apply additional regional filtering logic.

calendar.public.holiday.line

Technical name: calendar.public.holiday.line
Description: Calendar Public Holiday Line
Default ordering: date, name desc
Each record represents a single holiday on a specific date within a holiday set. On creation, a corresponding calendar.event (all-day, busy, tagged Public Holidays) is automatically created and kept in sync for the lifetime of the line.

Fields

name
Char
required
Human-readable holiday name, e.g. "Christmas Day".
date
Date
required
The date on which this holiday falls. Must belong to the same calendar year as the parent public_holiday_id.year.
public_holiday_id
Many2one → calendar.public.holiday
required
Parent holiday set. Deletion of the parent cascades to all its lines (ondelete="cascade").
variable_date
Boolean
Indicates whether the holiday’s date changes from year to year (e.g. Easter). Defaults to True. Used as a hint when copying sets to a new year.
state_ids
Many2many → res.country.state
Optional restriction to specific states or provinces. When empty, the holiday applies nationally. The relation table is public_holiday_state_rel.
meeting_id
Many2one → calendar.event
Auto-managed linked calendar event. This field is set automatically on create() and is not copied when the record is duplicated (copy=False).

Constraints

The _check_date_state_one() validator enforces two rules:
  1. The date.year must equal public_holiday_id.year.
  2. No two lines in the same holiday set may share the same date unless they target completely disjoint state sets. A line with no states (state_ids = False) cannot co-exist with another state-agnostic line on the same date within the same set.

Calendar Event Lifecycle


Wizard: calendar.public.holiday.next.year

Technical name: calendar.public.holiday.next.year
Description: Create Public Holiday From Existing Ones
Type: TransientModel
This wizard copies holiday lines from one or more existing sets into a new year. It is the recommended way to create the next year’s holidays when the dates are predictable (fixed-date holidays).

Fields

public_holiday_ids
Many2many → calendar.public.holiday
Template holiday sets to copy from. When left empty, the wizard falls back to all existing holiday sets in the database. If multiple sets for the same country are selected, only the most recent set per country is used as a template.
year
Integer
Target year for the new holiday sets. When left at 0, each template’s year is incremented by one (last_ph.year + 1).

Methods

create_public_holidays()

def create_public_holidays(self):
Iterates over the resolved templates, creates new calendar.public.holiday records for year, then copies each line with its date shifted to the target year (date.replace(year=new_year)). Raises UserError if any template line falls on February 29 (a leap-day holiday). Handling such cases would require knowing whether the target year is also a leap year, which is left to the user. On success, returns an ir.actions.act_window action that opens the newly created holiday sets in a list/form view.
Always select templates from a non-leap year (avoid sets from 2016, 2020, 2024, …) unless you are certain the target year is also a leap year and you have manually adjusted the February 29 line beforehand.

Build docs developers (and LLMs) love