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

[13.0][MIG] stock_storage_type #12

Merged
merged 16 commits into from
Jun 30, 2020

Conversation

grindtildeath
Copy link
Contributor

@grindtildeath grindtildeath commented Jan 9, 2020

Copy link
Contributor

@simahawk simahawk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG, please rebase and run pre-commit

@grindtildeath
Copy link
Contributor Author

Rebase done.

@simahawk @guewen @jgrandguillaume Here I'm wondering if we shouldn't merge stock_storage_type_putaway_strategy (#13) into this module, because stock_storage_type only defines fields that are unused and don't make any sense by themselves, i.e. without the other module to compute putaways and restrict stock moves according to storage types...

@simahawk
Copy link
Contributor

@grindtildeath you miss server-tools dependency

odoo.exceptions.UserError: ("You try to install module 'stock_storage_type' that depends on module 'base_m2m_custom_field'.\nBut the latter module is not available in your system.", '')

Copy link
Contributor

@jbaudoux jbaudoux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about extracting the location storage type in a separate module that allows to define restrictions on the location (empty, do not mix) without needing package.

This module would add the allowed storage type concept on the location storage type and manage package.

) % (pack_storage_type.name, location.name)
)
allowed = False
package_quants = quant.package_id.mapped('quant_ids')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The constrain is evaluated at quant creation. At this stage, the package's quant is not up to date.

stock.quant(148,)
(Pdb) self.package_id
stock.quant.package(111,)
(Pdb) self.package_id.quant_ids
stock.quant()

other_quants_in_location = self.search(
[
('location_id', '=', location.id),
('id', 'not in', package_quants.ids)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We must exclude all previous quants that are not there anymore, i.e. quantity = 0

Suggested change
('id', 'not in', package_quants.ids)
('id', 'not in', package_quants.ids),
('quantity', '!=', 0)

loc_storage_types = location.allowed_location_storage_type_ids
if (
not quant.package_id
or not pack_storage_type
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would still evaluate the location storage type constrain like do not mix product even if the pack storage type is not defined and even if there is not package. This condition (having a package with a storage type) is only for the "lst_allowed_for_pst" check. For the other checks, we can still apply them based only the location storage type constrain

@gurneyalex
Copy link
Member

grindtildeath#5 fixes some performance issues

guewen added a commit to guewen/wms that referenced this pull request May 18, 2020
guewen added a commit to grindtildeath/wms that referenced this pull request Jun 5, 2020
We will never do a put-away in an intermediate location,
so they should never be kept as candidate locations for the
put-away.

Follow the change in OCA#12
@guewen guewen force-pushed the 13.0-mig-stock_storage_type branch 2 times, most recently from 19fd0cf to ef111b2 Compare June 5, 2020 14:34
Copy link
Contributor

@jbaudoux jbaudoux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fixes and perf improvements

Copy link
Member

@jgrandguillaume jgrandguillaume left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested & approved

grindtildeath and others added 7 commits June 24, 2020 18:00
…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
guewen and others added 3 commits June 24, 2020 18:00
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 <guewen.baconnier@camptocamp.com>
Co-authored-by: Akim Juillerat <akim.juillerat@camptocamp.com>
@grindtildeath
Copy link
Contributor Author

I squashed all the commits with a group by authors. Hope this is fine for everyone involved

@guewen
Copy link
Member

guewen commented Jun 25, 2020

I squashed all the commits with a group by authors. Hope this is fine for everyone involved

Not such a big deal, but a commit message that contains 'do X AND Y', pretty often means you should have 2 separate changes.
For instance, the commit that replaces the XML domain by the field domain using web_domain_field was a good atomic commit that I intended to use as an example for a blog post. Now, if you want to understand, you have to read the whole commit message and reverse engineer what part of the commit's diff is related to what part of the commit's message.

Ref good to keep in mind: https://blog.mocoso.co.uk/talks/2015/01/12/telling-stories-through-your-commits/

Anyway, the test should be fixed by my last fixup, I'll squash it if the tests pass.

@guewen guewen force-pushed the 13.0-mig-stock_storage_type branch from 6da22cd to ab7042a Compare June 25, 2020 09:36
guewen and others added 6 commits June 25, 2020 11:54
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
Required by stock_storage_type
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).
@guewen guewen force-pushed the 13.0-mig-stock_storage_type branch from ab7042a to 4cb1cab Compare June 25, 2020 10:04
@guewen
Copy link
Member

guewen commented Jun 30, 2020

/ocabot merge patch

@OCA-git-bot
Copy link
Contributor

Hey, thanks for contributing! Proceeding to merge this for you.
Prepared branch 13.0-ocabot-merge-pr-12-by-guewen-bump-patch, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit febbb82 into OCA:13.0 Jun 30, 2020
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 3691279. Thanks a lot for contributing to OCA. ❤️

grindtildeath pushed a commit to grindtildeath/wms that referenced this pull request Jul 6, 2020
We will never do a put-away in an intermediate location,
so they should never be kept as candidate locations for the
put-away.

Follow the change in OCA#12
dreispt pushed a commit to ursais/wms that referenced this pull request Nov 9, 2022
We will never do a put-away in an intermediate location,
so they should never be kept as candidate locations for the
put-away.

Follow the change in OCA#12
rousseldenis pushed a commit to acsone/wms that referenced this pull request Nov 16, 2022
We will never do a put-away in an intermediate location,
so they should never be kept as candidate locations for the
put-away.

Follow the change in OCA#12
rousseldenis pushed a commit to acsone/wms that referenced this pull request May 19, 2023
We will never do a put-away in an intermediate location,
so they should never be kept as candidate locations for the
put-away.

Follow the change in OCA#12
rousseldenis pushed a commit to acsone/wms that referenced this pull request Sep 18, 2023
We will never do a put-away in an intermediate location,
so they should never be kept as candidate locations for the
put-away.

Follow the change in OCA#12
rousseldenis pushed a commit to acsone/wms that referenced this pull request Sep 18, 2023
We will never do a put-away in an intermediate location,
so they should never be kept as candidate locations for the
put-away.

Follow the change in OCA#12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants