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

[17.0] [MIG] stock_storage_type: Migration to 17.0 #974

Draft
wants to merge 176 commits into
base: 17.0
Choose a base branch
from

Conversation

alexandregaldeano
Copy link

@alexandregaldeano alexandregaldeano commented Jan 21, 2025

grindtildeath and others added 30 commits January 17, 2025 12:05
…dule

Define max height/max weight restriction fields

Dedicated tree view to edit package/location storage type relation

Rename fields to drop stock_ prefix
Add tests

Fix dependency issue for pytest

[IMP] pre-commit XML files

Add setuptools

Add module stock_storage_type_putaway_strategy

[IMP] stock_storage_type_putaway_strategy: black, isort

[MIG] stock_storage_type_putaway_strategy: Migration to 13.0

Compute domain on stock.package_level location_dest_id according to storage_type restrictions

Allow to compute restrictions for multiple products and quants

Add constraint on stock.quant according to stock_storage_type

Add tests

Add tests on package destination domain

Add package_level actual location to allowed domain

Fix constraints do not mix products/lots
Fix failing test and add loggers

Improve error message on stock.quant constraint
Check waiting moves in "Not Empty" put-away constraints

When an unreserved move's destination is already a bin, we assume:

* the move is probably waiting on another that will be processed soon
* as the destination of the move is already a bin (not Stock, ...), the
  good *will* arrive in this precise location and not another

So we prevent new move lines to target this location.

Note: as we do not know the lot yet in the move, we cannot check if we
have a planned lot for the same lot in the "Do not mix same lot": ignore
it.
improve perfs
* in _compute_allowed_location_dest_ids handle the case of a missing pack level, and short cut
* move a mapped() call out of a loop
* use the stored related field state of stock.move.line instead of a dotted path in the search domain
The choice of a suitable stock location was implemented using an
iteration on all candidate locations + several filters running for each.
This is not efficient when we have several 1000s of locations (each
check was taking 30ms -> several minutes required to compute a putaway
location). This commit reimplements the algorithm by using queries to
select locations matching the rules. In order to be able to compute this
using the ORM, we added some technical fields which should not harm
performance too much.

Co-authored-by: Guewen Baconnier <[email protected]>
Co-authored-by: Akim Juillerat <[email protected]>
We will never do a put-away in an intermediate location,
so they should never be kept as candidate locations for the
put-away.
Which is much smaller with thousands of locations for a couple of
storage types.

I recycled the field location_ids on the location storage type which
was a unused field (probably forgotten during a refactoring).
When we select a package in a package level, we want to restrict
the selection of the location destination based on the put-away rules.

The previous implementation used a computed M2m field, added in the
view as an invisible field, and a domain on the location_dest_id field
filtering the locations based on this m2m.

The issue: with 5000 allowed locations, changing the package triggers
an onchange (that we want), and the server answers with 5000 ids,
which must be processed by the M2m field client side. It blocks
the browser for several seconds.

The module web_domain_field [0] allow to use a domain stored in a Char
field rather than a field in the XML (read the module's description if
not clear). Using it solves this issue, as the client doesn't need to
evaluate and update a m2m field, it only pass the domain downstream.

[0] https://github.com/OCA/web/tree/13.0/web_domain_field
It may be a valid use case, for instance to be able to send the good on
the "zone" above the bins (with a following new move to go from the Zone
to the bin).
The putaway sequence for a package storage types defines where the goods
can be put and in which order.

For instance, if the "cardbox" storage type has this sequence:

1. Stock/Cardboxes Shelving: ordered locations
2. Stock/Cardboxes Reserve: ordered locations

It will first try to put the goods in Bin 1, then Bin 2 and finally Bin
3 if the others are full.

This commit aims to support the strategies with a 'none' strategy has
valid locations in the sequences, such as:

1. Stock: None
2. Stock/Cardboxes Shelving: ordered locations
3. Stock/Cardboxes Reserve: ordered locations

In this example, if a move line with a cardbox has a destination Stock,
no strategy will be applied, if the move line has a destination Cardbox
Shelving, the ordered location strategy is applied.

It allows to use a sort of buffer: the default destination is Stock,
then the destination is updated to Stock/Cardbox Reserve (upon the
choice of a user!) and a new computation of the putaway is asked.
Package storage type can be defined on products to compute automatically
a package storage type on packages if no packaging is defined and
the package only contains a single product.
The putaway based on storage type *must* be applied at the very end
of the putaway rules, because it depends on the putaway location found.

If we execute it by calling super() and we added different putaway
strategies in StockLocation, we have no way to be sure it is the last
called.

That's why now it depends on stock_putaway_hook, which allow to search
for alternative put-away hooks, and call _putaway_strategy_finalizer at
the very end, where we can plug the storage type rules.
OCA-git-bot and others added 21 commits January 17, 2025 12:05
Currently translated at 100.0% (110 of 110 strings)

Translation: wms-16.0/wms-16.0-stock_storage_type
Translate-URL: https://translation.odoo-community.org/projects/wms-16-0/wms-16-0-stock_storage_type/it/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: wms-16.0/wms-16.0-stock_storage_type
Translate-URL: https://translation.odoo-community.org/projects/wms-16-0/wms-16-0-stock_storage_type/
Currently translated at 100.0% (110 of 110 strings)

Translation: wms-16.0/wms-16.0-stock_storage_type
Translate-URL: https://translation.odoo-community.org/projects/wms-16-0/wms-16-0-stock_storage_type/it/
Currently translated at 100.0% (110 of 110 strings)

Translation: wms-16.0/wms-16.0-stock_storage_type
Translate-URL: https://translation.odoo-community.org/projects/wms-16-0/wms-16-0-stock_storage_type/it/
Currently translated at 100.0% (110 of 110 strings)

Translation: wms-16.0/wms-16.0-stock_storage_type
Translate-URL: https://translation.odoo-community.org/projects/wms-16-0/wms-16-0-stock_storage_type/it/
As Odoo does not void directly a quant after a full quant transfer (quant
remains with quantity == 0), consider that quantity when computing the fields
to avoid mixed products or mixed lots
Currently translated at 100.0% (110 of 110 strings)

Translation: wms-16.0/wms-16.0-stock_storage_type
Translate-URL: https://translation.odoo-community.org/projects/wms-16-0/wms-16-0-stock_storage_type/it/
@alexandregaldeano alexandregaldeano marked this pull request as draft January 21, 2025 13:47
@alexandregaldeano alexandregaldeano force-pushed the 17.0-mig-stock_storage_type branch 6 times, most recently from f33d0b1 to 3cd8f51 Compare January 21, 2025 15:33
@alexandregaldeano alexandregaldeano force-pushed the 17.0-mig-stock_storage_type branch from 3cd8f51 to c08064c Compare January 21, 2025 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.