-
-
Notifications
You must be signed in to change notification settings - Fork 666
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_putaway_hook: Migration to 17.0 #1842
base: 17.0
Are you sure you want to change the base?
[17.0] [MIG] stock_putaway_hook: Migration to 17.0 #1842
Conversation
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.
…eturn a location mer 05 oct 2022 12:41:58 From v15, the _get_putaway_strategy() method on stock locations shoul always return a location.
Currently translated at 100.0% (2 of 2 strings) Translation: stock-logistics-workflow-16.0/stock-logistics-workflow-16.0-stock_putaway_hook Translate-URL: https://translation.odoo-community.org/projects/stock-logistics-workflow-16-0/stock-logistics-workflow-16-0-stock_putaway_hook/it/
2c96171
to
8140862
Compare
/ocabot migration stock_putaway_hook |
@alexandregaldeano Thanks for this. A test with |
8140862
to
3fa31bd
Compare
@rousseldenis that was a great suggestion, I understand more how this code works. I have added tests as you suggested. But now I'm questioning whether the _get_view override is useful at all. I have added the following test to check what was the behavior without the module: 95a9784#diff-0c5186a1fcedfbbd1cd6b4d951d6a372b6c527330313759f55edb1f9e4a4f0a7R74 |
3fa31bd
to
95a9784
Compare
fields_view_get
to_get_view
and within it,attrs
updates have been replaced by direct attributes changesodoo_test_helper
as test dependency