Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][ADD] stock_storage_category_usage_report #352

Open
wants to merge 5 commits into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions setup/stock_storage_category_usage_report/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,
)
96 changes: 96 additions & 0 deletions stock_storage_category_usage_report/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
===================================
Stock Storage Category Usage Report
===================================

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

.. |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_storage_category_usage_report
: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_storage_category_usage_report
: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=16.0
:alt: Try me on Runboat

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

This module allows to get reporting on stock storage categories about
their locations usage.

|Usage Report|

.. |Usage Report| image:: https://raw.githubusercontent.com/OCA/stock-logistics-reporting/16.0/stock_storage_category_usage_report/static/description/usage_report.png

**Table of contents**

.. contents::
:local:

Use Cases / Context
===================

When users want to manage their stock locations in a better way, they
need those locations' usage (empty/filled in).

Usage
=====

- Go to Inventory > Analysis > Stock Storage Category Usage Report
- Each category will contain a fill rate depending on the occupation of
all its children locations. It will display also the number of empty
and filled locations.
- The fill rate is also present on storage categories level.

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_storage_category_usage_report%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
------------

- Denis Roussel [email protected]

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_storage_category_usage_report>`_ 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_storage_category_usage_report/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
22 changes: 22 additions & 0 deletions stock_storage_category_usage_report/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2024 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Stock Storage Category Usage Report",
"summary": """
This module allows to get reporting on stock storage categories
about their locations usage""",
Comment on lines +5 to +8
Copy link
Contributor

Choose a reason for hiding this comment

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

What about renaming to use fill instead of usage as this relates to that field?

Suggested change
"name": "Stock Storage Category Usage Report",
"summary": """
This module allows to get reporting on stock storage categories
about their locations usage""",
"name": "Stock Storage Category Fill Report",
"summary": """
This module allows to get reporting on stock storage categories
about their locations fill rate""",

"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/stock-logistics-reporting",
"depends": [
"stock",
"stock_location_children",
"stock_location_fill_state",
"web_widget_progressbar_gradient",
],
"data": [
"views/stock_storage_category.xml",
],
}
73 changes: 73 additions & 0 deletions stock_storage_category_usage_report/i18n/fr_BE.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Translation of Odoo Server.
Copy link
Contributor

Choose a reason for hiding this comment

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

Rename file to fr.po

# This file contains the translation of the following modules:
# * stock_storage_category_usage_report
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-11-19 13:25+0000\n"
"PO-Revision-Date: 2024-11-19 13:25+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: stock_storage_category_usage_report
#: model:ir.model.fields,field_description:stock_storage_category_usage_report.field_stock_storage_category__empty_location_ids
msgid "Empty Location"
msgstr "Emplacement vide"

#. module: stock_storage_category_usage_report
#: model:ir.model.fields,field_description:stock_storage_category_usage_report.field_stock_storage_category__empty_location_count
msgid "Empty Location Count"
msgstr "Nombre d'emplacements vides"

#. module: stock_storage_category_usage_report
#: model:ir.model.fields,field_description:stock_storage_category_usage_report.field_stock_storage_category__fill_rate
msgid "Fill Rate"
msgstr "Taux de remplissage"

#. module: stock_storage_category_usage_report
#: model:ir.model.fields,field_description:stock_storage_category_usage_report.field_stock_storage_category__filled_location_ids
msgid "Filled Location"
msgstr "Emplacement occupé"

#. module: stock_storage_category_usage_report
#: model:ir.model.fields,field_description:stock_storage_category_usage_report.field_stock_storage_category__filled_location_count
msgid "Filled Location Count"
msgstr "Nombre d'emplacements remplis"

#. module: stock_storage_category_usage_report
#: model:ir.actions.act_window,name:stock_storage_category_usage_report.report_storage_category_usage_act_window
#: model:ir.ui.menu,name:stock_storage_category_usage_report.report_storage_category_root_menu
#: model:ir.ui.menu,name:stock_storage_category_usage_report.report_storage_category_view_menu
msgid "Stock Storage Category Usage Report"
msgstr "Rapport d'utilisation des catégories d'empalcement"
Copy link
Contributor

@jbaudoux jbaudoux Nov 20, 2024

Choose a reason for hiding this comment

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

:) ou Rapport de taux de remplissage

Suggested change
msgstr "Rapport d'utilisation des catégories d'empalcement"
msgstr "Rapport d'utilisation des catégories d'emplacements"


#. module: stock_storage_category_usage_report
#: model:ir.model,name:stock_storage_category_usage_report.model_stock_storage_category
msgid "Storage Category"
msgstr "Catégories d'emplacement"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
msgstr "Catégories d'emplacement"
msgstr "Catégorie d'emplacement"


#. module: stock_storage_category_usage_report
#: model:ir.model.fields,help:stock_storage_category_usage_report.field_stock_storage_category__empty_location_ids
msgid "These are the empty locations having this storage category"
msgstr "Ce sont les emplacements vides qui ont cette catégorie"

#. module: stock_storage_category_usage_report
#: model:ir.model.fields,help:stock_storage_category_usage_report.field_stock_storage_category__filled_location_ids
msgid "These are the filled locations having this storage category"
msgstr "Ce sont les emplacements remplis qui ont cette catégorie"

#. module: stock_storage_category_usage_report
#: model:ir.model.fields,help:stock_storage_category_usage_report.field_stock_storage_category__empty_location_count
msgid "This is the number of empty locations having this storage category"
msgstr "Le nombre d'emplacement vides qui ont cette catégorie"

#. module: stock_storage_category_usage_report
#: model:ir.model.fields,help:stock_storage_category_usage_report.field_stock_storage_category__filled_location_count
msgid "This is the number of occupied locations having this storage category"
msgstr "Le nombre d'emplacements occupés qui ont cette catégorie"
1 change: 1 addition & 0 deletions stock_storage_category_usage_report/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import stock_storage_category
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Copyright 2024 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import api, fields, models


class StockStorageCategory(models.Model):

_inherit = "stock.storage.category"

empty_location_ids = fields.Many2many(
comodel_name="stock.location",
compute="_compute_empty_location_ids",
help="These are the empty locations having this storage category",
)
filled_location_ids = fields.Many2many(
comodel_name="stock.location",
compute="_compute_empty_location_ids",
help="These are the filled locations having this storage category",
)
empty_location_count = fields.Integer(
compute="_compute_empty_location_ids",
search="_search_empty_location_count",
help="This is the number of empty locations having this storage category",
)
filled_location_count = fields.Integer(
compute="_compute_empty_location_ids",
help="This is the number of occupied locations having this storage category",
)
fill_rate = fields.Float(
compute="_compute_empty_location_ids",
)

def _get_locations_for_usage_report(self):
# Return all storage locations and their children that
# are not views.
self.ensure_one()
return (self.location_ids | self.location_ids.children_ids).filtered(
lambda location: location.usage != "view"
)

@api.depends("location_ids.children_ids")
def _compute_empty_location_ids(self):
for category in self:
all_locations = category._get_locations_for_usage_report()
# Empty locations are locations empty and being emptied
# (move qty is done but not yet validated).
# We don't take into account filled and being filled moves.
empty_locations = all_locations.filtered(
lambda location: location.fill_state == "empty"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
lambda location: location.fill_state == "empty"
lambda location: location.fill_state in ("empty", "being_emptied")

)
filled_locations = all_locations - empty_locations
if all_locations:
fill_rate = float(
100 - ((len(empty_locations) / len(all_locations)) * 100)
)
else:
fill_rate = 0.0

Check warning on line 57 in stock_storage_category_usage_report/models/stock_storage_category.py

View check run for this annotation

Codecov / codecov/patch

stock_storage_category_usage_report/models/stock_storage_category.py#L57

Added line #L57 was not covered by tests
category.update(
{
"empty_location_ids": empty_locations.ids,
"filled_location_ids": filled_locations.ids,
"filled_location_count": len(filled_locations),
"empty_location_count": len(empty_locations),
"fill_rate": fill_rate,
}
)
2 changes: 2 additions & 0 deletions stock_storage_category_usage_report/readme/CONTEXT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
When users want to manage their stock locations in a better way,
they need those locations' usage (empty/filled in).
Copy link
Contributor

@jbaudoux jbaudoux Nov 20, 2024

Choose a reason for hiding this comment

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

Maybe DESCRIPTION is enough. It's kind of repeating

Suggested change
they need those locations' usage (empty/filled in).
they need those location storage categories' fill rate (amount of empty/filled location).

1 change: 1 addition & 0 deletions stock_storage_category_usage_report/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Denis Roussel <[email protected]>
4 changes: 4 additions & 0 deletions stock_storage_category_usage_report/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This module allows to get reporting on stock storage categories
about their locations usage.

![Usage Report](../static/description/usage_report.png)
5 changes: 5 additions & 0 deletions stock_storage_category_usage_report/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- Go to Inventory > Analysis > Stock Storage Category Usage Report
- Each category will contain a fill rate depending on the
occupation of all its children locations. It will display also
the number of empty and filled locations.
- The fill rate is also present on storage categories level.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading