Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
76927b6
[16.0][ADD] stock_average_daily_sale
rousseldenis Jan 13, 2023
6a08cb3
[IMP] stock_average_daily_sale: Store the configurations on profile l…
rousseldenis Feb 14, 2023
24da91d
[IMP] stock_average_daily_sale: Improve profile view
rousseldenis Feb 15, 2023
b68b2ad
[IMP] Remove zone location dependency, rely on warehouse only
rousseldenis Jul 13, 2023
c84556e
[IMP] stock_average_daily_sale: Improve tests
rousseldenis Jul 13, 2023
0972a77
[IMP] stock_average_daily_sale: Improve module helps / change field n…
rousseldenis Jul 13, 2023
3c1f2b4
[FIX] stock_average_daily_sale: Don't exclude moves on priority
lmignon Jul 31, 2023
720b1b8
[IMP] stock_average_daily_sale: Don't use Odoo demo data
rousseldenis Sep 15, 2023
d0c4a12
[IMP] stock_average_daily_sale: add contributor
sbejaoui Oct 4, 2023
76949d3
[IMP] stock_average_daily_sale: Avoid errors in all searches and retu…
rousseldenis Oct 10, 2023
418fae6
[FIX] stock_average_daily_sale: Use a new cursor to avoid closed one
rousseldenis Oct 11, 2023
d2f3ee6
[FIX] stock_average_daily_sale: Don't test the not refreshed material…
rousseldenis Oct 11, 2023
ef74524
[FIX] stock_average_daily_sale: Don't check the view existence in tests
rousseldenis Oct 11, 2023
a9762f3
[FIX] stock_average_daily_sale: Don't rely on tuples as id
rousseldenis Oct 11, 2023
2e883e9
[IMP] stock_average_daily_sale: avoid concurrent update
lmignon Nov 21, 2023
8e4ee93
[UPD] Update stock_average_daily_sale.pot
Apr 15, 2024
dec61ff
[BOT] post-merge updates
OCA-git-bot Apr 15, 2024
e32e610
Added translation using Weblate (Italian)
mymage Apr 19, 2024
ddcb73a
Translated using Weblate (Italian)
mymage Apr 23, 2024
eb5e2ef
stock_average_daily_sale: Remove product_abc_classification dependency
twalter-c2c Aug 27, 2024
ea59984
stock_average_daily_sale: Change default access rights
twalter-c2c Aug 27, 2024
2349d76
stock_average_daily_sale: Set default root location on WH
twalter-c2c Aug 27, 2024
033be95
stock_average_daily_sale: Allow to include/exclude weekends
twalter-c2c Aug 27, 2024
c9f83e5
stock_average_daily_sale: Take production location into account
twalter-c2c Aug 27, 2024
b8a136a
stock_average_daily_sale: Config adjustment - add from view and compa…
twalter-c2c Aug 27, 2024
deb1602
stock_average_daily_sale: Pre-migration script
twalter-c2c Sep 13, 2024
3760faf
stock_average_daily_sale: Specify WH on demo stock moves
twalter-c2c Sep 23, 2024
0b69fe6
[UPD] Update stock_average_daily_sale.pot
Sep 24, 2024
905d470
[BOT] post-merge updates
OCA-git-bot Sep 24, 2024
2e9ea08
Update translation files
weblate Sep 24, 2024
5485044
Translated using Weblate (Italian)
mymage Sep 26, 2024
4b6c1b9
stock_average_daily_sale: refactor
jbaudoux Apr 4, 2025
3a1cdf1
stock_average_daily_sale: improve fields visibility
jbaudoux Apr 7, 2025
bdbad17
[UPD] Update stock_average_daily_sale.pot
Apr 25, 2025
87c0829
[BOT] post-merge updates
OCA-git-bot Apr 25, 2025
5ffb6b0
Update translation files
weblate Apr 25, 2025
3019c99
Translated using Weblate (Italian)
mymage Apr 28, 2025
a57f5e0
[IMP] stock_average_daily_sale: pre-commit autofixes
rousseldenis Mar 12, 2026
58cc98f
[MIG] stock_average_daily_sale: Migration to 18.0
rousseldenis Mar 12, 2026
27c782c
[FIX] stock_average_daily_sale: Don't translate sql constraint
rousseldenis Mar 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# generated from manifests external_dependencies
freezegun
165 changes: 165 additions & 0 deletions stock_average_daily_sale/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
========================
Stock Average Daily Sale
========================

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

.. |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/licence-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--reporting-lightgray.png?logo=github
:target: https://github.com/OCA/stock-logistics-reporting/tree/18.0/stock_average_daily_sale
:alt: OCA/stock-logistics-reporting
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/stock-logistics-reporting-18-0/stock-logistics-reporting-18-0-stock_average_daily_sale
: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-reporting&target_branch=18.0
:alt: Try me on Runboat

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

This module allows to gather stock consumptions and build reporting for
average daily consumptions. Technically, this has been done through a
materialized postgresql view in order to be as fast as possible (some
other flow modules can depend on this).

You can add several configurations depending on the location from which
consumptions are counted.

For each product ABC classification, you can define the computation
horizon, i.e. the amount of time to look backward (in days or weeks or
months or years).

You can exclude some days of the week like saturday and sunday from the
computation. However, if moves occurs on those excluded days, they are
still counted. If your warehouse is open usualy on week days, the
averages will be on 5 days a week. If the warehouse had some activity
during the week-end, this will be considered in the total and average as
if it happened during weekdays.

The report also provides a recommended quantity. That recommended
quantity is the biggest between: - a coverage in days \* the average
daily consumption + a safety - a coverage in days \* the average
consumption

The second part tries to better recommend a quantity for C products. The
safety is computed as: daily standard deviation \* sqrt(coverage) \* a
safety factor It is up to you to configure the safety factor.

**Table of contents**

.. contents::
:local:

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

- To configure data analysis, you should go to Inventory > Configuration
> Average daily sales computation parameters

- You need to fill in the following informations:

- The product ABC classification you want - see
product_abc_classification module
- The concerned warehouse
- The stock location for which you want to compute the usage
- The period of time to analyze back (in days/weeks/months/years)
- A safety factor

- Go to Configuration > Technical > Scheduled Actions > Refresh average
daily sales materialized view

By default, the scheduled action is set to refresh data each day. Note
that the current day is not take into consideration in the
computations, so you better run the scheduled action on the early
morning.

WARNING: The current query is not TZ compliant. So the cron must run
after midnight UTC time.

- By default, the root location where analysis is done is the Warehouse
stock location, but you can change it and you can compute usage for
multiple locations of the warehouse. Ensure to set a location that is
used by the stock moves or a parent one.

Known issues / Roadmap
======================

- Allow to exclude specific days
- An extensible data gathering query
- Make it timezone compliant

Changelog
=========

16.0.1.0.0 (2023-01-13)
-----------------------

- [16.0][ADD] stock_average_daily_sale

16.0.2.0.0 (2025-04-05)
-----------------------

- [16.0][REF] refactor formulas for proper metrics

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-reporting/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-reporting/issues/new?body=module:%20stock_average_daily_sale%0Aversion:%2018.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
-------

* ACSONE SA/NV
* BCIM

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

- Laurent Mignon <laurent.mignon@acsone.eu>
- Denis Roussel <denis.roussel@acsone.eu>
- Jacques-Etienne Baudoux (BCIM) <je@bcim.be>
- Tomasz Walter <tomasz.walter@camptocamp.com>

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-jbaudoux| image:: https://github.com/jbaudoux.png?size=40px
:target: https://github.com/jbaudoux
:alt: jbaudoux

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

|maintainer-jbaudoux|

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

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions stock_average_daily_sale/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models, wizards
31 changes: 31 additions & 0 deletions stock_average_daily_sale/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2023 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Stock Average Daily Sale",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rename the module to

Suggested change
"name": "Stock Average Daily Sale",
"name": "Stock Average Daily Usage",

"summary": """
Allows to gather consumed products on daily basis""",
"version": "18.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV,BCIM,Odoo Community Association (OCA)",
"maintainers": ["jbaudoux"],
"website": "https://github.com/OCA/stock-logistics-reporting",
"depends": [
"sale",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should only depend on stock

"stock_storage_type_putaway_abc",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to drop this strong dependency and move it to a glue module. Or even better, replace it with a products applicability domain. At the end, it is the only thing that it is doing.

Also it would be better to use the abc product classification level that is at product.product level (abc_storage is only at product.template level) and that supports multi-warehouses through the abc profiles.

"product_route_mto",

@jbaudoux jbaudoux Apr 14, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MTO should move to another glue module. It doesn't provide any value to this ADU computation.

New module: stock_average_daily_usage_mto

],
"data": [
"security/stock_average_daily_sale_config.xml",
"security/stock_average_daily_sale.xml",
"security/stock_average_daily_sale_demo.xml",
"views/stock_average_daily_sale_config.xml",
"views/stock_average_daily_sale.xml",
"data/ir_cron.xml",
],
"external_dependencies": {"python": ["freezegun"]},
"demo": [
"demo/stock_average_daily_sale_config.xml",
"demo/stock_move.xml",
],
}
13 changes: 13 additions & 0 deletions stock_average_daily_sale/data/ir_cron.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<record forcecreate="True" id="refresh_materialized_view" model="ir.cron">
<field name="name">Refresh average daily sales materialized view</field>
<field name="active" eval="True" />
<field name="user_id" ref="base.user_root" />
<field name="interval_number">24</field>
<field name="interval_type">hours</field>
<field name="model_id" ref="model_stock_average_daily_sale" />
<field name="code">model.refresh_view()</field>
<field name="state">code</field>
</record>
</odoo>
44 changes: 44 additions & 0 deletions stock_average_daily_sale/demo/stock_average_daily_sale_config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2021 ACSONE SA/NV
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo noupdate="1">
<record
model="stock.average.daily.sale.config"
id="stock_average_daily_sale_config_level_a"
>
<field name="abc_classification_level">a</field>
<field name="period_value">2</field>
<field name="period_name">week</field>
<field name="safety_factor">0.3</field>
<field name="number_days_qty_in_stock">2</field>
<field name="exclude_weekends">1</field>
<field name="warehouse_id" ref="stock.warehouse0" />
<field name="company_id" ref="base.main_company" />
</record>
<record
model="stock.average.daily.sale.config"
id="stock_average_daily_sale_config_level_b"
>
<field name="abc_classification_level">b</field>
<field name="period_value">13</field>
<field name="period_name">week</field>
<field name="safety_factor">0.3</field>
<field name="number_days_qty_in_stock">2</field>
<field name="exclude_weekends">1</field>
<field name="warehouse_id" ref="stock.warehouse0" />
<field name="company_id" ref="base.main_company" />
</record>
<record
model="stock.average.daily.sale.config"
id="stock_average_daily_sale_config_level_c"
>
<field name="abc_classification_level">c</field>
<field name="period_value">26</field>
<field name="period_name">week</field>
<field name="safety_factor">0.3</field>
<field name="number_days_qty_in_stock">2</field>
<field name="exclude_weekends">1</field>
<field name="warehouse_id" ref="stock.warehouse0" />
<field name="company_id" ref="base.main_company" />
</record>
</odoo>
6 changes: 6 additions & 0 deletions stock_average_daily_sale/demo/stock_move.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2023 ACSONE SA/NV
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo noupdate="1">
<function model="stock.average.daily.sale.demo" name="_action_create_data" />
</odoo>
Loading
Loading