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

[18.0][MIG] stock_helper: Migration to 18.0. (split feature to stock_route_location_source) #2283

Open
wants to merge 34 commits into
base: 18.0
Choose a base branch
from

Conversation

mt-software-de
Copy link
Contributor

To complete the Migration of stock_helper started with #2223
This PR split the method for getting the source location of a route into a own addon.
The initial method _get_source_location_from_route was moved to stock.route and renamed to _get_source_location.

cc @ThiagoMForgeFlow @jbaudoux @LoisRForgeFlow @JasminSForgeFlow

guewen and others added 30 commits March 7, 2025 13:03
The first method is: StockLocation.is_sublocation_of()

This method is currently used in:

* wms/stock_dynamic_routing
* wms/shopfloor
* wms/stock_move_source_relocate
* stock-logistics-warehouse/stock_reserve_rule
* ddmrp/ddmrp

The goal will be to use this module as dependency instead of
reimplementing the method in each.

Other methods should follow in "stock_helper".

Note: I opened odoo/odoo#53866 to propose a
generic version of this method, expecting odoo's opinion, but got no
answer.
Currently translated at 100.0% (1 of 1 strings)

Translation: stock-logistics-warehouse-16.0/stock-logistics-warehouse-16.0-stock_helper
Translate-URL: https://translation.odoo-community.org/projects/stock-logistics-warehouse-16-0/stock-logistics-warehouse-16-0-stock_helper/hr/
returns the next source location of a location by the given route and procure_method
Currently translated at 100.0% (1 of 1 strings)

Translation: stock-logistics-warehouse-16.0/stock-logistics-warehouse-16.0-stock_helper
Translate-URL: https://translation.odoo-community.org/projects/stock-logistics-warehouse-16-0/stock-logistics-warehouse-16-0-stock_helper/it/
Since this change in v17
odoo/odoo@439ca89
_get_rule fallbacks to location's warehouse to check for routes.
This makes that the receipt route is found by _get_source_location_from_route.
However, this is the case only with `stock` module installed, because
as soon as `mrp` or `purchase` is installed that first step of the receipt
route get removed in favor of manufacture or purchase routes. See
odoo/odoo@d25d320
Copy link
Contributor

@LoisRForgeFlow LoisRForgeFlow left a comment

Choose a reason for hiding this comment

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

Thanks! looks like the tests are failing, could you check?

class StockRoute(models.Model):
_inherit = "stock.route"

def _get_source_location(self, location, procure_method):
Copy link
Contributor

Choose a reason for hiding this comment

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

What about having this as a computed field?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At the moment it is just used here. And here it is just quite specific.
https://github.com/OCA/stock-logistics-orderpoint/blob/31cfed56eebf1cef7422f2adda4b40b876832554/stock_location_orderpoint/models/stock_location_orderpoint.py#L128

But it is not possible to implement it as computed method, because you need a least a location as argument otherwise you cannot find a src location.

But after thinking about your question, i don't know it this method is needed at all.
Because it is only once used and very specific. And for stock_location_orderpoint it also easier to figure out what the src location is.
For example in stock_location_orderpoint we could just filter the rules of the route.
location_src = orderpoint.route_id.rule_ids.filtered(lambda rule: rule.location_id == orderpoint.location_id and rule.procure_method == 'make_to_stock').location_src_id

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also this is not correct that it can be simplified. Because the main issue is here that i'm just talking from a very easy route rule configuration. So something a need is created in Stock take it from stock2.
But if it it would be a more complex configuration this is not working it all.
If it is a more complex route we need to set from the last make_to_stock rule the location src.
This also would mean that we need to remove the route from the call.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will update this feature and propose a change.

@mt-software-de mt-software-de force-pushed the 18.0-mig-stock_helper branch from daec473 to a700971 Compare March 8, 2025 10:21
@mt-software-de mt-software-de force-pushed the 18.0-mig-stock_helper branch from 3d7f637 to 5fe0647 Compare March 8, 2025 12:27
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.