Skip to content

Commit

Permalink
Merge PR #257 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by jbaudoux
  • Loading branch information
OCA-git-bot committed Apr 15, 2024
2 parents 469d732 + d46c24f commit 4635017
Show file tree
Hide file tree
Showing 34 changed files with 1,836 additions and 0 deletions.
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ select = C,E,F,W,B,B9
ignore = E203,E501,W503
per-file-ignores=
__init__.py:F401
stock_average_daily_sale/models/stock_average_daily_sale.py:B950
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
6 changes: 6 additions & 0 deletions setup/stock_average_daily_sale/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
123 changes: 123 additions & 0 deletions stock_average_daily_sale/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
========================
Stock Average Daily Sale
========================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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/16.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-16-0/stock-logistics-reporting-16-0-stock_average_daily_sale
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/151/16.0
:alt: Try me on Runbot

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

This module allows to gather stock consumptions and build reporting for average daily
sales (aka stock 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 window you want to analyze.
So, you can define criteria to filter data:

* The Warehouse
* The product ABC classification
* The location kind (Zone, Area, Bin)
* The amount of time to look backward (in days or weeks or months or years)

Moreover, you can define:

* A safety factor
* A standard deviation exclusion 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 kind (Zone, Area, Bin) - see stock_location_zone module
* The period of time to analyze back (in days/weeks/months/years)
* A standard deviation exclusion factor
* A safety factor

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

By default, the sceduled action is set to refresh data each 4 hours. You can change
that depending on your needs.

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

* Move the filter on saturday/sunday to configuration parameters
* An extensible data gathering query

Changelog
=========

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

* [16.0][ADD] stock_average_daily_sale

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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/stock-logistics-reporting/issues/new?body=module:%20stock_average_daily_sale%0Aversion:%2016.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

Contributors
~~~~~~~~~~~~

* Laurent Mignon <laurent.mignon@acsone.eu>
* Denis Roussel <denis.roussel@acsone.eu>

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.

This module is part of the `OCA/stock-logistics-reporting <https://github.com/OCA/stock-logistics-reporting/tree/16.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
34 changes: 34 additions & 0 deletions stock_average_daily_sale/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright 2023 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Stock Average Daily Sale",
"summary": """
Allows to gather delivered products average on daily basis""",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV,BCIM,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/stock-logistics-reporting",
"depends": [
"sale",
"stock_storage_type_putaway_abc",
"product_abc_classification",
"product_abc_classification_sale_stock",
"product_route_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",
"views/abc_classification_profile.xml",
"views/stock_warehouse.xml",
"data/ir_cron.xml",
],
"external_dependencies": {"python": ["freezegun"]},
"demo": [
"demo/stock_average_daily_sale_config.xml",
"demo/stock_move.xml",
],
}
16 changes: 16 additions & 0 deletions stock_average_daily_sale/data/ir_cron.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?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">4</field>
<field name="interval_type">hours</field>
<field name="numbercall">-1</field>
<field name="doall" eval="False" />
<field name="model_id" ref="model_stock_average_daily_sale" />
<field name="code">model.refresh_view()</field>
<field name="state">code</field>
</record>

</odoo>
50 changes: 50 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,50 @@
<?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_profile_id"
ref="product_abc_classification_sale_stock.abc_classification_profile_sale_stock"
/>
<field name="abc_classification_level">a</field>
<field name="period_value">2</field>
<field name="period_name">week</field>
<field name="standard_deviation_exclude_factor">3</field>
<field name="safety_factor">0.3</field>
<field name="number_days_qty_in_stock">2</field>
</record>
<record
model="stock.average.daily.sale.config"
id="stock_average_daily_sale_config_level_b"
>
<field
name="abc_classification_profile_id"
ref="product_abc_classification_sale_stock.abc_classification_profile_sale_stock"
/>
<field name="abc_classification_level">b</field>
<field name="period_value">13</field>
<field name="period_name">week</field>
<field name="standard_deviation_exclude_factor">3</field>
<field name="safety_factor">0.3</field>
<field name="number_days_qty_in_stock">2</field>
</record>
<record
model="stock.average.daily.sale.config"
id="stock_average_daily_sale_config_level_c"
>
<field
name="abc_classification_profile_id"
ref="product_abc_classification_sale_stock.abc_classification_profile_sale_stock"
/>
<field name="abc_classification_level">c</field>
<field name="period_value">26</field>
<field name="period_name">week</field>
<field name="standard_deviation_exclude_factor">3</field>
<field name="safety_factor">0.3</field>
<field name="number_days_qty_in_stock">2</field>
</record>
</odoo>
7 changes: 7 additions & 0 deletions stock_average_daily_sale/demo/stock_move.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?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>
4 changes: 4 additions & 0 deletions stock_average_daily_sale/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from . import stock_warehouse # isort:skip
from . import stock_average_daily_sale_config # isort:skip
from . import stock_average_daily_sale # isort:skip
from . import abc_classification_profile
15 changes: 15 additions & 0 deletions stock_average_daily_sale/models/abc_classification_profile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2023 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class AbcClassificationProfile(models.Model):

_inherit = "abc.classification.profile"

stock_average_daily_sale_config_ids = fields.One2many(
comodel_name="stock.average.daily.sale.config",
inverse_name="abc_classification_profile_id",
string="Average Daily Sale Configurations",
)
Loading

0 comments on commit 4635017

Please sign in to comment.