Skip to content
ERPForAll DocsDevelopment

    Calendar view

    A calendar view places a model’s records on a day, week, month or year grid by a start and an optional stop field. An addon declares it in a view file and adds calendar to the action’s view_mode; no code is needed.

    <record id="loan_calendar" model="ir.ui.view">
    <field name="name">sample_library.loan.calendar</field>
    <field name="model">sample_library.loan</field>
    <field name="arch" type="xml">
    <calendar string="Loans" date_start="loan_date" date_stop="due_date" color="borrower_id" mode="month">
    <field name="book_id"/>
    <field name="borrower_id" filters="1"/>
    <field name="state" filters="1"/>
    <field name="return_date"/>
    </calendar>
    </field>
    </record>
    <record id="loan_action" model="ir.actions.act_window">
    <field name="res_model">sample_library.loan</field>
    <field name="view_mode">list,form,calendar</field>
    </record>
    AttributeMeaningDefault
    date_startRequired. A stored date or datetime field: where an event startsnone (refused when absent)
    date_stopA field of the same type: where it stopsthe event stops where it starts
    all_dayA boolean field: the event covers whole daysevents of a date field are always all-day
    colorA many2one or integer field: events with the same value share a palette colour (11 colours, cycled)no colour
    modeThe scale shown first: day, week, month or yearweek when offered, else the first scale
    scalesThe scales offered, comma separated, in toolbar orderall four
    create, edit, delete, quick_create, month_overflowStatic booleans (0/1, True/False)on
    hide_date, hide_timeLeave the date or the time out of an event’s “When” lineoff
    event_limitEvents shown in one month cell before “+n more” (1 to 50)5

    edit="0" labels the popover button Open instead of Edit; delete="0" removes Delete. create and quick_create are carried in the description for later; creating, moving and resizing events from the calendar is not available yet.

    Each <field name="..."/> is shown in the event popover, labelled with string or the field’s label; invisible="1" leaves it out. filters="1" on a many2one or selection field adds a side-panel section with one checkbox per value found in the visible range; its values are filtered in memory, without a read. When the filter field is also the colour field, each value shows its colour.

    Everything the first calendar slices do not carry is refused when the view loads, never ignored (SPEC-VIEW-241): a missing or wrongly typed date field, an unknown or repeated scale, a mode outside scales, an event_limit outside 1 to 50, an expression in a flag, other child elements, a field named twice. These reference attributes are refused with a message saying they are not available yet: aggregate, event_open_popup, form_view_id, create_name_field, quick_create_view_id, multi_create_view, show_unusual_days, show_date_picker, schedule, js_class, <popover>, and on fields widget, options, color, avatar_field, write_model, write_field, filter_field, and filters on other field kinds. Odoo 20 has no date_delay; it is an unknown attribute here too.

    The calendar’s root fields are needed to place an event: a user who cannot read one of them gets an access error for the whole calendar. A <field> child the user cannot read is left out of the popover and the side panel (SPEC-VIEW-243).

    The client reads the records of the visible range with web_search_read: the search domain, then a range domain “starts on or before the last moment of the range, and stops on or after its first moment (or has no stop and starts in the range)”. Datetime bounds are computed in the user’s time zone and sent in UTC; date bounds are plain days. Weeks start on Monday. The read asks for one record more than the setting web.calendar_max_events (Settings, database-wide; default 1,000, floor 50, hard bound 20,000); when that record comes back the range is refused with a message naming the setting, and nothing is drawn (SPEC-VIEW-242).

    The page address keeps calendar_scale (day, week, month, year) and calendar_date (YYYY-MM-DD). Both are checked by the server’s address policy and by the client; a malformed value, or a scale the calendar does not offer, is refused by name (SPEC-VIEW-244).

    Behaviour matrix: docs/design/m4-calendar-matrix.md. User guide: docs/user/calendar-view.md.