OdooWiki OCA HUB

Base Time Window

base_time_window folder_open OCA/server-tools open_in_new
Technical Settings License: LGPL-3

This module provides base classes and models to manage time windows through time.window.mixin.

auto_awesome What this module does

AI-generated from the code · Odoo 19.0

Provides reusable building blocks (a weekday list and a time-window mixin) so other Odoo modules can define opening hours or availability slots with automatic overlap and validity checks.

This is a technical foundation module: it does not add a menu or a screen of its own, but it gives other modules the tools to describe "from hour to hour on these weekdays" periods.

It creates a weekday reference list (Monday to Sunday) that is loaded automatically and can be read by any internal user, but not modified from the interface.

It also defines a reusable time-window template that other models can inherit. On those models it adds three fields: a start hour, an end hour and a list of weekdays. Several automatic rules apply:

  • The end hour must be later than the start hour, otherwise saving is blocked with an error message.
  • At least one weekday must be selected.
  • Hours must stay between 00 and 23, so a window cannot exceed 24 hours.
  • When a model declares a grouping field, the module checks the database and refuses to save a window that overlaps another window on the same weekdays and same group.

The record name shown in lists is built automatically, for example "Monday, Tuesday: From 08:00 to 12:00". Helper functions convert the stored decimal hours into readable times and can compute the next date matching a given weekday, which other modules use for scheduling.

Depends on

base
Models and fields (2)
  • time.weekday · new modelname
  • time.window.mixin · new modeltime_window_end (To), time_window_start (From), time_window_weekday_ids

Text generated by AI (DeepSeek) from reading the Odoo 19.0 code on GitHub; it may contain mistakes, so check the code before deciding. View the code on GitHub

Availability by version

Reviewed: 2026-11-03
Confirmed (verified in repository and branch) Estimated (unverified) No information

Confirmation status: 7 confirmed, 2 with no information of 9 versions.

Sources · Odoo 14.0

Confirmed on 2026-11-03 in branch 14.0 of OCA/server-tools.

terminal Installation and usage

OCA documentation · Odoo 19.0

Example implementation for the mixin can be found in module test_base_time_window.

As a time window will always be linked to a related model thourgh a M2o relation, when defining the new model inheriting the mixin, one should pay attention to the following points in order to have the overlapping check work properly:

  • Define class property _overlap_check_field: This must state the M2o field to use for the to check of overlapping time window records linked to a specific record of the related model.
  • Add the M2o field to the related model in the api.constrains:

For example:

class PartnerTimeWindow(models.Model):
    _name = 'partner.time.window'
    _inherit = 'time.window.mixin'

    partner_id = fields.Many2one(
        res.partner', required=True, index=True, ondelete='cascade'
    )

    _overlap_check_field = 'partner_id'

    @api.constrains('partner_id')
    def check_window_no_overlaps(self):
        return super().check_window_no_overlaps()

No verified information in OCA: Installation, Configuration.

info

Data imported from GitHub: this sheet reflects the latest catalog review, not a live lookup. Always check the module documentation and staging before installing in production.