Odoo Community Association

Stock Removal Zone-Level FIFO

Beta License: AGPL-3 OCA/stock-logistics-reservation Translate me on Weblate Try me on Runboat

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

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:

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. 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.

Do not contact contributors directly about support or help with technical issues.

Credits

Authors

  • Camptocamp
  • BCIM

Contributors

Maintainers

This module is maintained by the OCA.

Odoo Community Association

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.

Current maintainer:

jbaudoux

This module is part of the OCA/stock-logistics-reservation project on GitHub.

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