Skip to content

Commit

Permalink
[16.0][ADD] stock_location_fill_state
Browse files Browse the repository at this point in the history
  • Loading branch information
rousseldenis committed Nov 19, 2024
1 parent b94a8a1 commit 964a55b
Show file tree
Hide file tree
Showing 18 changed files with 897 additions and 0 deletions.
6 changes: 6 additions & 0 deletions setup/stock_location_fill_state/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,
)
104 changes: 104 additions & 0 deletions stock_location_fill_state/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
=========================
Stock Location Fill State
=========================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:33831d7106babe5129a20c0882ec8ae9c9e4d256c460a5dae0620e5a63e6b7dd
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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--warehouse-lightgray.png?logo=github
:target: https://github.com/OCA/stock-logistics-warehouse/tree/16.0/stock_location_fill_state
:alt: OCA/stock-logistics-warehouse
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-16-0/stock-logistics-warehouse-16-0-stock_location_fill_state
: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-warehouse&target_branch=16.0
:alt: Try me on Runboat

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

This module allows to identify empty stock locations. But also, filled
locations, being empty ones (some movements will empty the location) and
being filled ones (some movements are planned to fill in the location).

|occupancy|

.. |occupancy| image:: https://raw.githubusercontent.com/OCA/stock-logistics-warehouse/16.0/stock_location_fill_state/static/description/fill_state.png

**Table of contents**

.. contents::
:local:

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

Stock logistic managers need to know the void stock locations in order
to measure the capacity of the warehouse and be able to reorganize it if
it does not fit the current replenishment coverage.

Usage
=====

- Go to Inventory > Configuration > Warehouse Management > Locations
- In the list of locations, enable the column visibility 'Fill State'
- You can filter the locations per 'Empty' or 'Filled' property.

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

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

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

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

|maintainer-rousseldenis|

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

{
"name": "Stock Location Fill State",
"summary": """This module allows to identify the fill state of stock locations""",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/stock-logistics-warehouse",
"depends": ["base_partition", "stock", "stock_location_pending_move"],
"maintainers": ["rousseldenis"],
"data": [
"views/stock_location.xml",
],
}
72 changes: 72 additions & 0 deletions stock_location_fill_state/i18n/fr_BE.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_location_fill_state
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-11-19 08:27+0000\n"
"PO-Revision-Date: 2024-11-19 08:27+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_location_fill_state
#: model:ir.model.fields,help:stock_location_fill_state.field_stock_location__fill_state
msgid ""
"\n"
" This shows the location fill state.\n"
" Possible values:\n"
" [empty] Empty location\n"
" [filled] Filled location\n"
" [being_filled] The location is empty and an incoming move is in progress\n"
" [being_emptied] The location is filled and the outgoing move(s) will empty the location\n"
" "
msgstr ""
"\n"
" Ceci montre le statut de remplissage de l'emplacement.\n"
" Valeurs possibles:\n"
" [empty] Emplacement vide\n"
" [filled] Emplacement remplu\n"
" [being_filled] L'emplacement est vide et un mouvement entrant est en cours\n"
" [being_emptied] L'emplacement est rempli et un mouvement sortant en cours videra l'emplacement\n"
" "

#. module: stock_location_fill_state
#: model:ir.model.fields.selection,name:stock_location_fill_state.selection__stock_location__fill_state__being_emptied
#: model_terms:ir.ui.view,arch_db:stock_location_fill_state.stock_location_search_view
msgid "Being Emptied"
msgstr "Libération"

#. module: stock_location_fill_state
#: model:ir.model.fields.selection,name:stock_location_fill_state.selection__stock_location__fill_state__being_filled
#: model_terms:ir.ui.view,arch_db:stock_location_fill_state.stock_location_search_view
msgid "Being Filled"
msgstr "En réappro"

#. module: stock_location_fill_state
#: model:ir.model.fields.selection,name:stock_location_fill_state.selection__stock_location__fill_state__empty
#: model_terms:ir.ui.view,arch_db:stock_location_fill_state.stock_location_search_view
msgid "Empty"
msgstr "Vide"

#. module: stock_location_fill_state
#: model:ir.model.fields,field_description:stock_location_fill_state.field_stock_location__fill_state
#: model_terms:ir.ui.view,arch_db:stock_location_fill_state.stock_location_form_view
msgid "Fill State"
msgstr "Remplissage"

#. module: stock_location_fill_state
#: model:ir.model.fields.selection,name:stock_location_fill_state.selection__stock_location__fill_state__filled
#: model_terms:ir.ui.view,arch_db:stock_location_fill_state.stock_location_search_view
msgid "Filled"
msgstr "Rempli"

#. module: stock_location_fill_state
#: model:ir.model,name:stock_location_fill_state.model_stock_location
msgid "Inventory Locations"
msgstr "Emplacements de stock"
1 change: 1 addition & 0 deletions stock_location_fill_state/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import stock_location
77 changes: 77 additions & 0 deletions stock_location_fill_state/models/stock_location.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Copyright 2024 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from collections import defaultdict

from odoo import api, fields, models

from odoo.addons.stock_location_pending_move.models.stock_location import (
PENDING_MOVE_DOMAIN,
)


class StockLocation(models.Model):

_inherit = "stock.location"

fill_state = fields.Selection(
selection=[
("empty", "Empty"),
("filled", "Filled"),
("being_filled", "Being Filled"),
("being_emptied", "Being Emptied"),
],
compute="_compute_fill_state",
store=True,
index=True,
help="""
This shows the location fill state.
Possible values:
[empty] Empty location
[filled] Filled location
[being_filled] The location is empty and an incoming move is in progress
[being_emptied] The location is filled and the outgoing move(s) will empty the location
""",
)

@api.depends(
"quant_ids.quantity",
"pending_out_move_line_ids.qty_done",
"pending_in_move_ids",
"pending_in_move_line_ids",
)
def _compute_fill_state(self):
""" """
location_domain = [("location_id", "in", self.ids)]
out_qty_by_location = {}
qty_by_location = {}
for group in self.env["stock.move.line"].read_group(
PENDING_MOVE_DOMAIN + location_domain,
fields=["qty_done:sum"],
groupby=["location_id"],
):
location_id = group["location_id"][0]
out_qty_by_location[location_id] = group["qty_done"]
for group in self.env["stock.quant"].read_group(
location_domain, fields=["quantity:sum"], groupby=["location_id"]
):
location_id = group["location_id"][0]
qty_by_location[location_id] = group["quantity"]
records_by_state = defaultdict(lambda: self.browse())
for rec in self:
qty_in_location = qty_by_location.get(rec.id, 0.0)
out_by_location = out_qty_by_location.get(rec.id, 0.0)
if qty_in_location > 0.0:
records_by_state["filled"] |= rec
if qty_in_location <= 0.0:
records_by_state["empty"] |= rec
if out_by_location and (qty_in_location - out_by_location <= 0):
records_by_state["being_emptied"] |= rec
if (qty_in_location <= 0) and (
rec.pending_in_move_ids or rec.pending_in_move_line_ids
):
records_by_state["being_filled"] |= rec
for state, records in records_by_state.items():
# Don't update if value is already set
records.filtered(
lambda record: record.fill_state != state
).fill_state = state
3 changes: 3 additions & 0 deletions stock_location_fill_state/readme/CONTEXT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Stock logistic managers need to know the void stock locations in order to
measure the capacity of the warehouse and be able to reorganize it if
it does not fit the current replenishment coverage.
1 change: 1 addition & 0 deletions stock_location_fill_state/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Denis Roussel <[email protected]>
5 changes: 5 additions & 0 deletions stock_location_fill_state/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This module allows to identify empty stock locations. But also,
filled locations, being empty ones (some movements will empty the location)
and being filled ones (some movements are planned to fill in the location).

![occupancy](../static/description/fill_state.png)
3 changes: 3 additions & 0 deletions stock_location_fill_state/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Go to Inventory > Configuration > Warehouse Management > Locations
- In the list of locations, enable the column visibility 'Fill State'
- You can filter the locations per 'Empty' or 'Filled' property.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 964a55b

Please sign in to comment.