Calendars on Orderpoints

stock_calendar
REPOSITORY
REPOSITORYodoo/odoo
GIT
GIThttps://github.com/odoo/odoo.git
GIT FOLDER
GIT FOLDERhttps://github.com/odoo/odoo/tree/10.0/stock_calendar
VERSION
VERSION 1.0
CATEGORY
CATEGORYWarehouse
LICENSE
LICENSELGPL-3
APPLICATION
APPLICATIONNo
AUTO-INSTALLABLE
AUTO-INSTALLABLENo
AUTHORS
AUTHORS
MAINTAINERS
MAINTAINERS
COMMITTERS
COMMITTERSRaphael Collet, Odoo Translation Bot, Martin Trigaux, Olivier Dony, Thibault Delavallée, Denis Ledoux, Christophe Simonis, Nicolas Martinelli, Julien Legros, qdp-odoo, Yannick Tivisse
WEBSITE
WEBSITEhttps://www.odoo.com/page/warehouse
LAST TRACKING UPDATE
LAST TRACKING UPDATE2026-07-05 23:50:47
ODOO DEPENDENCIES
ODOO DEPENDENCIES odoo/odoo:
    - purchase
    - stock_account
    - stock
    - product
    - base
    - decimal_precision
    - mail
    - base_setup
    - web_kanban
    - web
    - bus
    - web_tour
    - report
    - procurement
    - barcodes
    - web_planner
    - account
    - analytic
    - resource
PYTHON DEPENDENCIES
PYTHON DEPENDENCIES Not have
SYSTEM DEPENDENCIES
SYSTEM DEPENDENCIES Not have
DESCRIPTION
DESCRIPTION
        The stock_calendar module handles minimum stock rules (=orderpoints / reordering rules) differently by
        the possibility to take into account the purchase and delivery calendars.

        Normally, the scheduler will go through all orderpoints and will create a procurement with a quantity taking
        into account the current stock and all future stock moves.  For companies working with fresh products, this is
        a problem, because if you order the products needed over 2 weeks now and they arrive tomorrow, then
        these products won't be fresh anymore in two weeks.

        To solve this, we added a delivery calendar to the orderpoint.  The future stock moves (they represent the needs)
        taken into account will be limited to those until the second delivery according to the calendar.
        So if I am delivered every week on Tuesday and on Friday, when I order on Monday, I will be delivered on Tuesday
        with all what is needed until Friday.

        This however is not good enough as you want to create a purchase order only before the date of the delivery as the
        future needs might change.  (otherwise you could have ordered too much already)  For this, we added a
        purchase calendar and the orderpoint will only be triggered when the scheduler is run within the time specified
        by the purchase calendar.  (a last execution date will also check if it has not already been triggered within this time)

        However, sometimes we have double orders: suppose we need to order twice on Friday: a purchase order for Monday
        and a purchase order for Tuesday.  Then we need to have two orders at the same time.
        To handle this, we put a procurement group on the calendar line and for the purchase calendar line we need to do,
        we will check the corresponding delivery line.  On the procurement group, we can tell to propagate itself to the purchase
        and this way it is possible to have an order for Monday and one for Tuesday.

        With normal orderpoints, the dates put on the purchase order are based on the delays in the system for the product/company.
        This does not correspond to what is done with the calendars, so the purchase/delivery dates will be set according to the calendars also.

        The calendars we use are on weekly basis.  It is possible however to have a start date and end date for e.g. the Tuesday delivery.
        It is also possible to put exceptions for days when there is none.
    

Code Analysis

Views touched (3)
XML IDNameModelTypeStatus
view_procurement_form_stock_inherit procurement.order.form.stock.inherit procurement.order field Inherits procurement.procurement_form_view
view_resource_calendar_attendance_tree_procurement_group resource.calendar.attendance.tree.procurement resource.calendar.attendance field Inherits resource.view_resource_calendar_attendance_tree
view_warehouse_orderpoint_form_inherit stock.warehouse.orderpoint.form.inherit stock.warehouse.orderpoint field Inherits stock.view_warehouse_orderpoint_form
Models touched (5)

New fields (2)
  • next_delivery_date Datetime
    help='The date of the next delivery for this procurement group, when this group is on the purchase calendar of the orderpoint' args: 'Next Delivery Date'
  • next_purchase_date Datetime
    help='The date the next purchase order should be sent to the vendor' args: 'Next Purchase Date'
Public methods (1)
  • assign_group_date(self)
    @api.multi

New fields (0)

No new fields.

Public methods (2)
  • get_leave_intervals(self, resource_id=None, start_datetime=None, end_datetime=None)
    @api.multi
    Get the leaves of the calendar. Leaves can be filtered on the resource, the start datetime or the end datetime. :param int resource_id: the id of the resource to take into account when computing the leaves. If not set, only general leaves are computed. If set, generic and specific leaves are computed. :param datetime start_datetime: if provided, do not take into account leaves ending before this date. :param datetime end_datetime: if provided, do not take into account leaves beginning after this date. :return list leaves: list of tuples (start_datetime, end_datetime) of leave intervals
  • interval_remove_leaves(self, interval, leave_intervals)
    @api.model
    Utility method that remove leave intervals from a base interval: - clean the leave intervals, to have an ordered list of not-overlapping intervals - initiate the current interval to be the base interval - for each leave interval: - finishing before the current interval: skip, go to next - beginning after the current interval: skip and get out of the loop because we are outside range (leaves are ordered) - beginning within the current interval: close the current interval and begin a new current interval that begins at the end of the leave interval - ending within the current interval: update the current interval begin to match the leave interval ending - take into account the procurement group when needed :param tuple interval: a tuple (beginning datetime, ending datetime) that is the base interval from which the leave intervals will be removed :param list leave_intervals: a list of tuples (beginning datetime, ending datetime) that are intervals to remove from the base interval :return list intervals: a list of tuples (begin datetime, end datetime) that are the remaining valid intervals

New fields (1)
  • group_id Many2one → procurement.group
    args: 'procurement.group', 'Procurement Group'
Public methods (0)

No public methods.

New fields (1)
  • group_id Many2one → procurement.group
    string='Procurement Group' args: 'procurement.group'
Public methods (0)

No public methods.

New fields (3)
  • calendar_id Many2one → resource.calendar
    help='In the calendar you can define the days that the goods will be delivered. That way the scheduler will only take into account the goods needed until the second delivery and put the procurement date as the first delivery.' args: 'resource.calendar', 'Calendar'
  • last_execution_date Datetime
    readonly=True args: 'Last Execution Date'
  • purchase_calendar_id Many2one → resource.calendar
    args: 'resource.calendar', 'Purchase Calendar'
Public methods (0)

No public methods.

REPOSITORY
REPOSITORYodoo/odoo
GIT
GIThttps://github.com/odoo/odoo.git
GIT FOLDER
GIT FOLDERhttps://github.com/odoo/odoo/tree/9.0/stock_calendar
VERSION
VERSION 1.0
CATEGORY
CATEGORYWarehouse
LICENSE
LICENSELGPL-3
APPLICATION
APPLICATIONNo
AUTO-INSTALLABLE
AUTO-INSTALLABLENo
AUTHORS
AUTHORS
MAINTAINERS
MAINTAINERS
COMMITTERS
COMMITTERSRaphael Collet, Odoo Translation Bot, Martin Trigaux, Fabien Pinckaers, Antony Lesuisse, Olivier Dony, Josse Colpaert, Nicolas Martinelli, Richard Mathot, Yannick Tivisse
WEBSITE
WEBSITEhttps://www.odoo.com/page/warehouse
LAST TRACKING UPDATE
LAST TRACKING UPDATE2026-07-05 23:48:30
ODOO DEPENDENCIES
ODOO DEPENDENCIES odoo/odoo:
    - purchase
    - stock_account
    - stock
    - product
    - base
    - decimal_precision
    - mail
    - base_setup
    - web_kanban
    - web
    - bus
    - report
    - procurement
    - barcodes
    - web_planner
    - account
    - analytic
    - web_tip
    - resource
PYTHON DEPENDENCIES
PYTHON DEPENDENCIES Not have
SYSTEM DEPENDENCIES
SYSTEM DEPENDENCIES Not have
DESCRIPTION
DESCRIPTION
        The stock_calendar module handles minimum stock rules (=orderpoints / reordering rules) differently by
        the possibility to take into account the purchase and delivery calendars.

        Normally, the scheduler will go through all orderpoints and will create a procurement with a quantity taking
        into account the current stock and all future stock moves.  For companies working with fresh products, this is
        a problem, because if you order the products needed over 2 weeks now and they arrive tomorrow, then
        these products won't be fresh anymore in two weeks.

        To solve this, we added a delivery calendar to the orderpoint.  The future stock moves (they represent the needs)
        taken into account will be limited to those until the second delivery according to the calendar.
        So if I am delivered every week on Tuesday and on Friday, when I order on Monday, I will be delivered on Tuesday
        with all what is needed until Friday.

        This however is not good enough as you want to create a purchase order only before the date of the delivery as the
        future needs might change.  (otherwise you could have ordered too much already)  For this, we added a
        purchase calendar and the orderpoint will only be triggered when the scheduler is run within the time specified
        by the purchase calendar.  (a last execution date will also check if it has not already been triggered within this time)

        However, sometimes we have double orders: suppose we need to order twice on Friday: a purchase order for Monday
        and a purchase order for Tuesday.  Then we need to have two orders at the same time.
        To handle this, we put a procurement group on the calendar line and for the purchase calendar line we need to do,
        we will check the corresponding delivery line.  On the procurement group, we can tell to propagate itself to the purchase
        and this way it is possible to have an order for Monday and one for Tuesday.

        With normal orderpoints, the dates put on the purchase order are based on the delays in the system for the product/company.
        This does not correspond to what is done with the calendars, so the purchase/delivery dates will be set according to the calendars also.

        The calendars we use are on weekly basis.  It is possible however to have a start date and end date for e.g. the Tuesday delivery.
        It is also possible to put exceptions for days when there is none.
    

Code Analysis

Views touched (3)
XML IDNameModelTypeStatus
view_procurement_form_stock_inherit procurement.order.form.stock.inherit procurement.order field Inherits procurement.procurement_form_view
view_resource_calendar_attendance_tree_procurement_group resource.calendar.attendance.tree.procurement resource.calendar.attendance field Inherits resource.view_resource_calendar_attendance_tree
view_warehouse_orderpoint_form_inherit stock.warehouse.orderpoint.form.inherit stock.warehouse.orderpoint field Inherits stock.view_warehouse_orderpoint_form
Models touched (0)

No models found for this module.