Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d454ebc

Browse files
committedNov 19, 2024·
[IMP] stock_storage_category_usage_report: Change dependency on stock_location_fill_rate
1 parent 7a760b7 commit d454ebc

File tree

9 files changed

+140
-54
lines changed

9 files changed

+140
-54
lines changed
 

‎stock_storage_category_usage_report/README.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Stock Storage Category Usage Report
77
!! This file is generated by oca-gen-addon-readme !!
88
!! changes will be overwritten. !!
99
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10-
!! source digest: sha256:286785e4ed90a55e72a7c3e927bb40d445678ac5ceafede2bc3ded649ff2fde6
10+
!! source digest: sha256:0053ca728015cbb69203234451fd3d51c413c65ebc82eda0572c52f0f3b7b93a
1111
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1212
1313
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
@@ -50,10 +50,10 @@ Usage
5050
=====
5151

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

5858
Bug Tracker
5959
===========

‎stock_storage_category_usage_report/__manifest__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"depends": [
1414
"stock",
1515
"stock_location_children",
16-
"stock_location_occupancy",
16+
"stock_location_fill_state",
1717
"web_widget_progressbar_gradient",
1818
],
1919
"data": [
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * stock_storage_category_usage_report
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 16.0+e\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"POT-Creation-Date: 2024-11-19 13:25+0000\n"
10+
"PO-Revision-Date: 2024-11-19 13:25+0000\n"
11+
"Last-Translator: \n"
12+
"Language-Team: \n"
13+
"MIME-Version: 1.0\n"
14+
"Content-Type: text/plain; charset=UTF-8\n"
15+
"Content-Transfer-Encoding: \n"
16+
"Plural-Forms: \n"
17+
18+
#. module: stock_storage_category_usage_report
19+
#: model:ir.model.fields,field_description:stock_storage_category_usage_report.field_stock_storage_category__empty_location_ids
20+
msgid "Empty Location"
21+
msgstr "Emplacement vide"
22+
23+
#. module: stock_storage_category_usage_report
24+
#: model:ir.model.fields,field_description:stock_storage_category_usage_report.field_stock_storage_category__empty_location_count
25+
msgid "Empty Location Count"
26+
msgstr "Nombre d'emplacements vides"
27+
28+
#. module: stock_storage_category_usage_report
29+
#: model:ir.model.fields,field_description:stock_storage_category_usage_report.field_stock_storage_category__fill_rate
30+
msgid "Fill Rate"
31+
msgstr "Taux de remplissage"
32+
33+
#. module: stock_storage_category_usage_report
34+
#: model:ir.model.fields,field_description:stock_storage_category_usage_report.field_stock_storage_category__filled_location_ids
35+
msgid "Filled Location"
36+
msgstr "Emplacement occupé"
37+
38+
#. module: stock_storage_category_usage_report
39+
#: model:ir.model.fields,field_description:stock_storage_category_usage_report.field_stock_storage_category__filled_location_count
40+
msgid "Filled Location Count"
41+
msgstr "Nombre d'emplacements remplis"
42+
43+
#. module: stock_storage_category_usage_report
44+
#: model:ir.actions.act_window,name:stock_storage_category_usage_report.report_storage_category_usage_act_window
45+
#: model:ir.ui.menu,name:stock_storage_category_usage_report.report_storage_category_root_menu
46+
#: model:ir.ui.menu,name:stock_storage_category_usage_report.report_storage_category_view_menu
47+
msgid "Stock Storage Category Usage Report"
48+
msgstr "Rapport d'utilisation des catégories d'empalcement"
49+
50+
#. module: stock_storage_category_usage_report
51+
#: model:ir.model,name:stock_storage_category_usage_report.model_stock_storage_category
52+
msgid "Storage Category"
53+
msgstr "Catégories d'emplacement"
54+
55+
#. module: stock_storage_category_usage_report
56+
#: model:ir.model.fields,help:stock_storage_category_usage_report.field_stock_storage_category__empty_location_ids
57+
msgid "These are the empty locations having this storage category"
58+
msgstr "Ce sont les emplacements vides qui ont cette catégorie"
59+
60+
#. module: stock_storage_category_usage_report
61+
#: model:ir.model.fields,help:stock_storage_category_usage_report.field_stock_storage_category__filled_location_ids
62+
msgid "These are the filled locations having this storage category"
63+
msgstr "Ce sont les emplacements remplis qui ont cette catégorie"
64+
65+
#. module: stock_storage_category_usage_report
66+
#: model:ir.model.fields,help:stock_storage_category_usage_report.field_stock_storage_category__empty_location_count
67+
msgid "This is the number of empty locations having this storage category"
68+
msgstr "Le nombre d'emplacement vides qui ont cette catégorie"
69+
70+
#. module: stock_storage_category_usage_report
71+
#: model:ir.model.fields,help:stock_storage_category_usage_report.field_stock_storage_category__filled_location_count
72+
msgid "This is the number of occupied locations having this storage category"
73+
msgstr "Le nombre d'emplacements occupés qui ont cette catégorie"

‎stock_storage_category_usage_report/models/stock_storage_category.py

+29-26
Original file line numberDiff line numberDiff line change
@@ -7,51 +7,54 @@ class StockStorageCategory(models.Model):
77

88
_inherit = "stock.storage.category"
99

10-
void_location_ids = fields.Many2many(
10+
empty_location_ids = fields.Many2many(
1111
comodel_name="stock.location",
12-
compute="_compute_void_location_ids",
13-
help="These are the void locations having this storage category",
12+
compute="_compute_empty_location_ids",
13+
help="These are the empty locations having this storage category",
1414
)
15-
occupied_location_ids = fields.Many2many(
15+
filled_location_ids = fields.Many2many(
1616
comodel_name="stock.location",
17-
compute="_compute_void_location_ids",
18-
help="These are the void locations having this storage category",
17+
compute="_compute_empty_location_ids",
18+
help="These are the filled locations having this storage category",
1919
)
20-
void_location_count = fields.Integer(
21-
compute="_compute_void_location_ids",
22-
search="_search_void_location_count",
23-
help="This is the number of void locations having this storage category",
20+
empty_location_count = fields.Integer(
21+
compute="_compute_empty_location_ids",
22+
search="_search_empty_location_count",
23+
help="This is the number of empty locations having this storage category",
2424
)
25-
occupied_location_count = fields.Integer(
26-
compute="_compute_void_location_ids",
25+
filled_location_count = fields.Integer(
26+
compute="_compute_empty_location_ids",
2727
help="This is the number of occupied locations having this storage category",
2828
)
29-
occupation_rate = fields.Float(
30-
compute="_compute_void_location_ids",
29+
fill_rate = fields.Float(
30+
compute="_compute_empty_location_ids",
3131
)
3232

3333
@api.depends("location_ids.children_ids")
34-
def _compute_void_location_ids(self):
34+
def _compute_empty_location_ids(self):
3535
for category in self:
3636
all_locations = (
3737
category.location_ids | category.location_ids.children_ids
3838
).filtered(lambda location: location.usage != "view")
39-
void_locations = all_locations.filtered(
40-
lambda location: not location.occupied
39+
# Empty locations are locations empty and being emptied
40+
# (move qty is done but not yet validated).
41+
# We don't take into account filled and being filled moves.
42+
empty_locations = all_locations.filtered(
43+
lambda location: location.fill_state == "empty"
4144
)
42-
occupied_locations = all_locations - void_locations
45+
filled_locations = all_locations - empty_locations
4346
if all_locations:
44-
occupation_rate = float(
45-
100 - ((len(void_locations) / len(all_locations)) * 100)
47+
fill_rate = float(
48+
100 - ((len(empty_locations) / len(all_locations)) * 100)
4649
)
4750
else:
48-
occupation_rate = 0.0
51+
fill_rate = 0.0
4952
category.update(
5053
{
51-
"void_location_ids": void_locations.ids,
52-
"occupied_location_ids": occupied_locations.ids,
53-
"occupied_location_count": len(occupied_locations),
54-
"void_location_count": len(void_locations),
55-
"occupation_rate": occupation_rate,
54+
"empty_location_ids": empty_locations.ids,
55+
"filled_location_ids": filled_locations.ids,
56+
"filled_location_count": len(filled_locations),
57+
"empty_location_count": len(empty_locations),
58+
"fill_rate": fill_rate,
5659
}
5760
)
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
- Go to Inventory > Analysis > Stock Storage Category Usage Report
2-
- Each category will contain a occupation rate depending on the
2+
- Each category will contain a fill rate depending on the
33
occupation of all its children locations. It will display also
4-
the number of void and occupied locations.
5-
- The occupation rate is also present on storage categories level.
4+
the number of empty and filled locations.
5+
- The fill rate is also present on storage categories level.

‎stock_storage_category_usage_report/static/description/index.html

+5-5
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ <h1 class="title">Stock Storage Category Usage Report</h1>
367367
!! This file is generated by oca-gen-addon-readme !!
368368
!! changes will be overwritten. !!
369369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370-
!! source digest: sha256:286785e4ed90a55e72a7c3e927bb40d445678ac5ceafede2bc3ded649ff2fde6
370+
!! source digest: sha256:0053ca728015cbb69203234451fd3d51c413c65ebc82eda0572c52f0f3b7b93a
371371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
372372
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/stock-logistics-reporting/tree/16.0/stock_storage_category_usage_report"><img alt="OCA/stock-logistics-reporting" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--reporting-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/stock-logistics-reporting-16-0/stock-logistics-reporting-16-0-stock_storage_category_usage_report"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-reporting&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
373373
<p>This module allows to get reporting on stock storage categories about
@@ -396,10 +396,10 @@ <h1><a class="toc-backref" href="#toc-entry-1">Use Cases / Context</a></h1>
396396
<h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
397397
<ul class="simple">
398398
<li>Go to Inventory &gt; Analysis &gt; Stock Storage Category Usage Report</li>
399-
<li>Each category will contain a occupation rate depending on the
400-
occupation of all its children locations. It will display also the
401-
number of void and occupied locations.</li>
402-
<li>The occupation rate is also present on storage categories level.</li>
399+
<li>Each category will contain a fill rate depending on the occupation of
400+
all its children locations. It will display also the number of empty
401+
and filled locations.</li>
402+
<li>The fill rate is also present on storage categories level.</li>
403403
</ul>
404404
</div>
405405
<div class="section" id="bug-tracker">
Loading

‎stock_storage_category_usage_report/tests/test_usage_report.py

+19-9
Original file line numberDiff line numberDiff line change
@@ -119,23 +119,33 @@ def setUpClass(cls):
119119

120120
@classmethod
121121
def _update_quantity(cls, product, location, quantity):
122-
cls.env["stock.quant"].with_context(inventory_mode=True).create(
123-
{"product_id": product.id, "location_id": location.id, "quantity": quantity}
124-
)._apply_inventory()
122+
quants = (
123+
cls.env["stock.quant"]
124+
.with_context(inventory_mode=True)
125+
.create(
126+
{
127+
"product_id": product.id,
128+
"location_id": location.id,
129+
"inventory_quantity": quantity,
130+
}
131+
)
132+
)
133+
quants._apply_inventory()
134+
return quants
125135

126136
def test_usage_report(self):
127-
self.assertEqual((self.large_shelf_2), self.storage_large.void_location_ids)
128-
self.assertEqual(1, self.storage_large.void_location_count)
129-
self.assertAlmostEqual(self.storage_large.occupation_rate, 66.67, places=2)
137+
self.assertEqual((self.large_shelf_2), self.storage_large.empty_location_ids)
138+
self.assertEqual(1, self.storage_large.empty_location_count)
139+
self.assertAlmostEqual(self.storage_large.fill_rate, 66.67, places=2)
130140
self.assertEqual(
131141
(self.medium_shelf_2 | self.medium_shelf_3),
132-
self.storage_medium.void_location_ids,
142+
self.storage_medium.empty_location_ids,
133143
)
134-
self.assertEqual(2, self.storage_medium.void_location_count)
144+
self.assertEqual(2, self.storage_medium.empty_location_count)
135145
self.storage_medium_void = self.storage_category.create(
136146
{
137147
"name": "Medium Storage Void",
138148
}
139149
)
140150
self.medium_shelf_3.storage_category_id = self.storage_medium_void
141-
self.assertEqual(self.storage_medium_void.occupation_rate, 0.0)
151+
self.assertEqual(self.storage_medium_void.fill_rate, 0.0)

‎stock_storage_category_usage_report/views/stock_storage_category.xml

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<xpath expr="//label[@for='max_weight']/parent::group" position="after">
1111
<group name="usage_report">
1212
<field
13-
name="occupation_rate"
13+
name="fill_rate"
1414
widget="progressbar_gradient"
1515
options="{'inverse': true}"
1616
/>
@@ -25,7 +25,7 @@
2525
<field name="arch" type="xml">
2626
<field name="allow_new_product" position="after">
2727
<field
28-
name="occupation_rate"
28+
name="fill_rate"
2929
widget="progressbar_gradient"
3030
options="{'inverse': true}"
3131
optional="hide"
@@ -40,10 +40,10 @@
4040
<field name="arch" type="xml">
4141
<tree>
4242
<field name="name" />
43-
<field name="void_location_count" />
44-
<field name="occupied_location_count" />
43+
<field name="empty_location_count" />
44+
<field name="filled_location_count" />
4545
<field
46-
name="occupation_rate"
46+
name="fill_rate"
4747
widget="progressbar_gradient"
4848
options="{'inverse': true}"
4949
/>

0 commit comments

Comments
 (0)
Please sign in to comment.