Metadata-Version: 2.1
Name: odoo-addon-stock_orderpoint_safety_stock
Version: 19.0.1.0.1.2
Requires-Dist: odoo==19.0.*
Requires-Dist: pyerf
Summary: Automatically compute the safety stock for orderpoints
Home-page: https://github.com/OCA/stock-logistics-orderpoint
License: AGPL-3
Author: Camptocamp, Odoo Community Association (OCA)
Author-email: support@odoo-community.org
Classifier: Programming Language :: Python
Classifier: Framework :: Odoo
Classifier: Framework :: Odoo :: 19.0
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
Description-Content-Type: text/x-rst

.. image:: https://odoo-community.org/readme-banner-image
   :target: https://odoo-community.org/get-involved?utm_source=readme
   :alt: Odoo Community Association

=============================
Stock Orderpoint Safety Stock
=============================

.. 
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   !! This file is generated by oca-gen-addon-readme !!
   !! changes will be overwritten.                   !!
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   !! source digest: sha256:34d08eee359a4099afc3bf15ba8d101f6cb7572027b43961631827b48bd6e6bf
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
    :target: https://odoo-community.org/page/development-status
    :alt: Beta
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
    :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
    :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--orderpoint-lightgray.png?logo=github
    :target: https://github.com/OCA/stock-logistics-orderpoint/tree/19.0/stock_orderpoint_safety_stock
    :alt: OCA/stock-logistics-orderpoint
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
    :target: https://translation.odoo-community.org/projects/stock-logistics-orderpoint-19-0/stock-logistics-orderpoint-19-0-stock_orderpoint_safety_stock
    :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
    :target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-orderpoint&target_branch=19.0
    :alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module enhances inventory management by introducing
service-level–based, stochastic control using a continuous review
replenishment system. Instead of relying solely on fixed min/max stock
levels, the module estimates your typical (mean) and variable (variance)
daily demand from historical data and factors in lead time. These
calculations generate a statistically sound safety stock, which is
included in your reorder threshold (the “min”). The “max” is set so your
inventory will cover expected demand during the entire replenishment
cycle.

Now, you can set replenishment rules (orderpoints) based on the **Cycle
Service Level (CSL)**, which reflects the probability of meeting all
demand during a replenishment cycle without running out of stock. This
provides a practical alternative to manually setting minimum and maximum
stock thresholds.

With CSL enabled, safety stock is automatically calculated using your
historical daily sales data (both average and standard deviation),
gathered over a period you define, plus the orderpoint’s lead time. The
system then keeps your reordering rule's min and max levels up-to-date.

Prefer manual control? You can always switch back to the “Manual” mode
to specify min and max directly.

Theory
------

The backbone of this approach is the Cycle Service Level (CSL), a widely
used supply chain metric:

- **CSL Definition:** The chance that your inventory will fully cover
  demand during a restocking cycle.
- **Example:** A CSL of 95% means that only 5% of cycles will risk a
  stockout.

This system assumes demand is random (not fixed), so it uses statistical
methods:

- **Average daily demand** (μ)
- **Standard deviation of daily demand** (σ)

Because demand can fluctuate during the lead time, safety stock acts as
a buffer to reduce the risk of running out of stock.

**Safety stock formula:**

``safety_stock = σ_L × z × g``

Where:

- **σ_L:** Standard deviation of demand over the lead time
- **z:** Z-score for your desired CSL (e.g., 1.65 for 95% CSL)
- **g:** Growth factor (optional, lets you add a margin)

**Three zones are needed to define how min and max are derived:**

- **Red zone = safety stock:**

  - This zone should never be touched. It acts as the buffer for
    unexpected variation.
  - Refer to the safety stock formula above.

- **Yellow zone = expected demand during the lead time:**

  - This zone represents the expected stock consumption from the moment
    you click on replenish, until the moment you receive your purchase
    order.
  - Formula: ``average daily demand × lead time in days``

- **Green zone = expected demand during the cycle:**

  - Represents the stock consumption during the desired reordering cycle
    (the time between two replenishments)
  - Formula: ``average daily demand × cycle days``

Where:

- **lead time:** The time it takes to receive the order.
- **cycle days:** The desired number of days between orders.

From these three zones, the min and max quantities are derived as
follows:

- **Minimum (min):** Red + Yellow
- **Maximum (max):** Red + Yellow + Green

**Why does it work?**

- Odoo triggers replenishment whenever stock falls below the min, which
  should be enough to cover variance (safety stock) and lead time
  demand.
- The max level is set high enough to cover all expected demand until
  the next restock, plus a buffer to cover the desired cycle days.

This makes inventory management both more data-driven and easier to
maintain.

|cycle-graph|

.. |cycle-graph| image:: https://raw.githubusercontent.com/OCA/stock-logistics-orderpoint/19.0/stock_orderpoint_safety_stock/static/description/cycle-graph.png

**Table of contents**

.. contents::
   :local:

Configuration
=============

To efficiently use this module, some configuration must be done in Odoo.

Demand History Days
-------------------

In the **General Settings >Inventory**, under *Advanced Scheduling*, you
have the possibility to set the **Demand History Days**.

It defines the rolling window for the historical analysis to compute the
average daily demand and resulting safety stock. Defaults to ``365``.
Company-specific.

|demand_history_days|

Cycle Service Levels
--------------------

They define the target probability of meeting all demand during a
replenishment cycle without running out of stock. The module comes with
predefined values for Cycle Service Levels and their z-scores, but you
can create more according to your needs.

|cycle_service_levels|

.. |demand_history_days| image:: https://raw.githubusercontent.com/OCA/stock-logistics-orderpoint/19.0/stock_orderpoint_safety_stock/static/description/settings-demand-history-days.png
.. |cycle_service_levels| image:: https://raw.githubusercontent.com/OCA/stock-logistics-orderpoint/19.0/stock_orderpoint_safety_stock/static/description/cycle-service-levels.png

Usage
=====

Set up your Replenishment Rules (Orderpoints) to use the **Cycle Service
Level** method, and play with the following variables to fit your needs.
The module will recompute daily the **Min**, **Max** and thus the **To
order** quantities based on the historical demand data and the
parameters you set.

Reordering Rule Parameters
--------------------------

**Safety Stock Method**

- **Manual**: The product's min and max quantities are set manually
  (standard Odoo behavior).
- **Cycle Service Level**: The product's min and max quantities are
  computed based on the target cycle service level, growth factor, order
  cycle and lead times.

**Cycle Service Level**

Defines the target probability of meeting all demand during a
replenishment cycle without running out of stock. Typical values range
from 90% to 99%. A higher target increases safety stock to reduce the
risk of stockouts; a lower target reduces inventory at the cost of more
frequent shortages.

**Cycle Days**

The desired number of days between orders. Used to size the gap between
the min and max quantities, to cover the expected demand during the
desired reordering cycle.

**Growth Factor**

An optional multiplier to account for expected growth in demand. Will be
applied to the safety stock and the resulting min and max quantities.

Additional information
----------------------

This module enhances the transparency of inventory management by
displaying the full calculation path for minimum and maximum stock
levels. By providing visibility into how safety stock formulas are
derived directly within the user interface, it builds user trust and
simplifies the verification of automated procurement rules.

When clicking on the ℹ️ icon, you are redirected to all the necessary
info & configuration needed to use this OCA module:

|orderpoint-tree-info|

|orderpoint-additional-info|

**Note:** Some fields are only shown in "Developer Mode".

Min & Max computation
---------------------

All the statistics and safety stock are non-stored fields computed
on-the-fly, while min & max quantities are computed either:

- Manually by clicking on the replenishment's 🔄 button

  |orderpoint-refresh-manual|

- Automatically by a daily scheduled action

  |orderpoint-refresh-cron|

Usability filters
-----------------

It's possible to filter on the safety stock method & on the cycle
service level in the Orderpoint tree view:

|orderpoint-filters|

.. |orderpoint-tree-info| image:: https://raw.githubusercontent.com/OCA/stock-logistics-orderpoint/19.0/stock_orderpoint_safety_stock/static/description/orderpoint-tree-info.png
.. |orderpoint-additional-info| image:: https://raw.githubusercontent.com/OCA/stock-logistics-orderpoint/19.0/stock_orderpoint_safety_stock/static/description/orderpoint-additional-info.png
.. |orderpoint-refresh-manual| image:: https://raw.githubusercontent.com/OCA/stock-logistics-orderpoint/19.0/stock_orderpoint_safety_stock/static/description/orderpoint-refresh-manual.png
.. |orderpoint-refresh-cron| image:: https://raw.githubusercontent.com/OCA/stock-logistics-orderpoint/19.0/stock_orderpoint_safety_stock/static/description/orderpoint-refresh-cron.png
.. |orderpoint-filters| image:: https://raw.githubusercontent.com/OCA/stock-logistics-orderpoint/19.0/stock_orderpoint_safety_stock/static/description/orderpoint-filters.png

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-orderpoint/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/stock-logistics-orderpoint/issues/new?body=module:%20stock_orderpoint_safety_stock%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Camptocamp

Contributors
------------

- Ivan Todorovich <ivan.todorovich@camptocamp.com>
- Gaëtan Vaujour <gaetan.vaujour@camptocamp.com>
- Jacques-Etienne Baudoux (BCIM) <je@bcim.be>

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
   :alt: Odoo Community Association
   :target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-ivantodorovich| image:: https://github.com/ivantodorovich.png?size=40px
    :target: https://github.com/ivantodorovich
    :alt: ivantodorovich

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-ivantodorovich| 

This module is part of the `OCA/stock-logistics-orderpoint <https://github.com/OCA/stock-logistics-orderpoint/tree/19.0/stock_orderpoint_safety_stock>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
