-
-
Notifications
You must be signed in to change notification settings - Fork 723
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
[16.0][MIG] stock_location_children #2190
base: 16.0
Are you sure you want to change the base?
[16.0][MIG] stock_location_children #2190
Conversation
* Any child_ids changed on a children_ids should recompute locations: otherwise only 2 levels are updated. * Flush any change in the hierarchy before executing the SQL
When other modules add locations in "stock.stock_location_stock", the assertions miss them. Create a new tree of locations to run the tests.
Currently translated at 100.0% (6 of 6 strings) Translation: stock-logistics-warehouse-14.0/stock-logistics-warehouse-14.0-stock_location_children Translate-URL: https://translation.odoo-community.org/projects/stock-logistics-warehouse-14-0/stock-logistics-warehouse-14-0-stock_location_children/it/
Currently translated at 100.0% (6 of 6 strings) Translation: stock-logistics-warehouse-14.0/stock-logistics-warehouse-14.0-stock_location_children Translate-URL: https://translation.odoo-community.org/projects/stock-logistics-warehouse-14-0/stock-logistics-warehouse-14-0-stock_location_children/it/
Currently translated at 100.0% (6 of 6 strings) Translation: stock-logistics-warehouse-14.0/stock-logistics-warehouse-14.0-stock_location_children Translate-URL: https://translation.odoo-community.org/projects/stock-logistics-warehouse-14-0/stock-logistics-warehouse-14-0-stock_location_children/it/
Improve readability of code without impacting performances
/ocabot migration stock_location_children |
fb036da
to
8eea61b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you 👍
8eea61b
to
1f54573
Compare
This PR has the |
query = """SELECT sub.id, ARRAY_AGG(sl2.id) AS children | ||
FROM stock_location sl2, | ||
( | ||
SELECT id, parent_path | ||
FROM stock_location sl | ||
) sub | ||
WHERE sl2.parent_path LIKE sub.parent_path || '%%' | ||
AND sl2.id != sub.id | ||
AND sub.id IN %s | ||
GROUP BY sub.id; | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe more readable than sub and sl2:
query = """SELECT sub.id, ARRAY_AGG(sl2.id) AS children | |
FROM stock_location sl2, | |
( | |
SELECT id, parent_path | |
FROM stock_location sl | |
) sub | |
WHERE sl2.parent_path LIKE sub.parent_path || '%%' | |
AND sl2.id != sub.id | |
AND sub.id IN %s | |
GROUP BY sub.id; | |
""" | |
query = """ | |
SELECT sl.id, ARRAY_AGG(child.id) AS children | |
FROM stock_location sl | |
JOIN stock_location child | |
ON child.parent_path LIKE sl.parent_path || '_%%' | |
AND sl.id IN %s | |
GROUP BY sl.id | |
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I didn't want to modify things that worked before.
supersedes #1802
Added some improvements