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

[14.0][MIG] stock_putaway_hook #772

Merged
merged 7 commits into from
Mar 8, 2021

Conversation

hparfr
Copy link
Contributor

@hparfr hparfr commented Jan 11, 2021

No description provided.

guewen and others added 6 commits January 11, 2021 16:09
Add hooks allowing modules to add more putaway strategies.
It adds hooks to the core putaway method
``StockLocation._get_putaway_strategy()`` allowing to plug other
strategies and makes the selector fields in the tree views dynamic
(required/readonly).

The fields_view_get override is to handle a tricky issue:

By default, the product_id field as such attrs:

"{'readonly': [('category_id', '!=', False)], 'required': [('category_id', '=', False)]}"

And the category_id field:

"{'readonly': [('product_id', '!=', False)], 'required': [('product_id', '=', False)]}"

If we add a new field "route_id", we want to extend the domains to
include it, such as:

"{'readonly': ['|', ('category_id', '!=', False), ('route_id '!=', False)],
  'required': [('category_id', '=', False), ('route_id', '=', False)]}"

And every new field will need to be added in the product_id and
category_id field, but also in the other fields (exemple, if we add a
"foo_id" field, it needs to be added in the attrs of "route_id"), which
isn't possible with the extension mechanisms of the XML views.

The solution provided by this module is that new fields must have the
{'exclusive_selection': True} in the options attribute, and an override
of fields_view_get automatically generates the attrs for all these
"exclusive" fields.

The code here will be tested by `stock_putaway_by_route` in a follow-up
commit.
The module matching a putaway rule by a route can now:

* find a putaway rule by the route related to a stock move
* or a route related to the product on the move

The changes required to enable this feature:

* In stock_putaway_hook: in the part that match the value, support "in"
  when the value is a container (recordset, list, tuple), so we can pass
  product.route_ids (and match any route set on a put-away rule)
* In stock_putaway_by_route, in the various parts where
  `StockLocation._get_putaway_strategy()` is called, propagate the
  product's routes as well
* In StockMoveLine.onchange_product_id, remove the computation based on
  self.move_id: it cannot change.
@hparfr
Copy link
Contributor Author

hparfr commented Jan 26, 2021

ping @guewen

@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@hparfr
Copy link
Contributor Author

hparfr commented Feb 10, 2021

Force pushed to make pre-commit happy.
It's mergeable now.

@hparfr
Copy link
Contributor Author

hparfr commented Mar 1, 2021

@rousseldenis can you please merge ?

@hparfr
Copy link
Contributor Author

hparfr commented Mar 8, 2021

/ocabot merge nobump

@OCA-git-bot
Copy link
Contributor

What a great day to merge this nice PR. Let's do it!
Prepared branch 14.0-ocabot-merge-pr-772-by-hparfr-bump-nobump, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 8151acb into OCA:14.0 Mar 8, 2021
@OCA-git-bot
Copy link
Contributor

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

@hparfr hparfr deleted the 14.0-mig-stock_putaway_hook branch March 8, 2021 08:58
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.

5 participants