Metadata-Version: 2.1
Name: odoo-addon-stock_removal_zone_fifo
Version: 18.0.1.0.0.2
Requires-Python: >=3.10
Requires-Dist: odoo==18.0.*
Summary: Removal strategy giving priority to the goods that entered a storage zone first
Home-page: https://github.com/OCA/stock-logistics-reservation
License: AGPL-3
Author: Camptocamp, BCIM, Odoo Community Association (OCA)
Author-email: support@odoo-community.org
Classifier: Programming Language :: Python
Classifier: Framework :: Odoo
Classifier: Framework :: Odoo :: 18.0
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
Classifier: Development Status :: 4 - Beta
Description-Content-Type: text/x-rst

.. image:: https://odoo-community.org/readme-banner-image
   :target: https://odoo-community.org/get-involved?utm_source=readme
   :alt: Odoo Community Association

=============================
Stock Removal Zone-Level FIFO
=============================

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

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

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

The standard FIFO removal strategy sorts the quants by incoming date
(``in_date``). That date is set when the goods are received and follows
them from location to location, so it cannot tell when they arrived in
the zone they are stored in: a pallet received long ago and only now
brought down to a picking area keeps its old incoming date, and the
picker is sent to it before the stock that has been sitting in that area
for weeks.

This module adds a **Zone-Level FIFO** removal strategy. It keeps the
FIFO principle but sorts on a new ``Zone Entry Date`` (``zone_in_date``)
field on the quant, falling back on the incoming date:

::

   zone_in_date, in_date, id

``zone_in_date`` changes only when the goods enter another zone, unlike
``in_date`` which a merge of stock or an inventory adjustment can move.
A zone is the nearest ancestor location carrying the strategy. It is
always set, so the sort above needs no NULL handling.

**Table of contents**

.. contents::
   :local:

Usage
=====

Set ``Zone-Level FIFO`` as the removal strategy of the parent location
of each picking zone. That location *is* the zone: every location under
it belongs to it, up to the next descendant carrying the strategy.

Do not set a removal strategy on the locations inside a zone: the
nearest one carrying it wins, so such a location would become a zone of
its own.

Setting the strategy on a **product category** only chooses how the
quants are sorted, it never defines a zone. A category-level Zone-Level
FIFO is therefore pointless on its own: without the strategy on at least
one location, no zone exists, ``zone_in_date`` is never updated and the
sort falls back on ``in_date``. Use the category to apply the strategy
warehouse-wide, and the locations to draw the zones.

Goods moved to a location that is in no zone keep their zone entry date,
since no zone sorts them there. Tick
``Update Zone Entry Date out of Zones`` in the Inventory settings to
give them the move date instead.

Goods entering a zone from a location in no zone always get a fresh
date: once out of every zone, nothing tells which zone they came from,
so Zone A -> Packing -> Zone B must count as a change of zone.

Development
===========

A zone is the nearest ancestor location, itself included, whose removal
strategy is zone-based. ``stock.location._get_zone_location()`` resolves
it, and ``_zone_removal_strategies()`` lists the strategy methods that
define one — a module adding another zone-based strategy extends that
list.

An extension module defining the zones differently overrides
``_get_zone_location`` on ``stock.location``:

.. code:: python

   def _get_zone_location(self):
       return <the zone of this location> or super()._get_zone_location()

``stock.location._is_same_zone(source_zone, destination_zone)`` decides
what counts as staying put: ``True`` keeps the date of the goods,
``False`` updates it. A destination in no zone answers ``True``, unless
the company setting ``zone_in_date_update_out_of_zone`` is on. Override
it to change that rule.

When the destination location already holds stock, the returned date
competes with the one already stored and the oldest of the two wins, so
arriving goods never push the ones already there back in the queue. This
mirrors the way the core keeps the oldest ``in_date`` when it merges
stock into an existing quant.

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

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

* Camptocamp
* BCIM

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

- David Gallay <david.gallay@camptocamp.com>
- Jacques-Etienne Baudoux (BCIM) <je@bcim.be>

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-reservation <https://github.com/OCA/stock-logistics-reservation/tree/18.0/stock_removal_zone_fifo>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
