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

[16.0][MIG] stock_location_children #2190

Open
wants to merge 20 commits into
base: 16.0
Choose a base branch
from

Conversation

rousseldenis
Copy link
Contributor

@rousseldenis rousseldenis commented Nov 8, 2024

supersedes #1802

Added some improvements

grindtildeath and others added 19 commits November 8, 2024 12:32
* 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
@rousseldenis
Copy link
Contributor Author

/ocabot migration stock_location_children

@OCA-git-bot OCA-git-bot added this to the 16.0 milestone Nov 8, 2024
@OCA-git-bot OCA-git-bot mentioned this pull request Nov 8, 2024
69 tasks
@rousseldenis
Copy link
Contributor Author

@grindtildeath

Copy link
Contributor

@grindtildeath grindtildeath left a comment

Choose a reason for hiding this comment

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

Thank you 👍

@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). 🤖

Comment on lines +27 to +37
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;
"""
Copy link
Contributor

@jbaudoux jbaudoux Nov 13, 2024

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:

Suggested change
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
"""

Copy link
Contributor Author

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.

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.