Skip to content

Instantly share code, notes, and snippets.

@grindtildeath
Created November 5, 2018 15:42
Show Gist options
  • Save grindtildeath/d0618f2f8170ebb5e1618a0e814edce4 to your computer and use it in GitHub Desktop.
Save grindtildeath/d0618f2f8170ebb5e1618a0e814edce4 to your computer and use it in GitHub Desktop.
odoo sql stock location tree
WITH RECURSIVE location_tree AS (
SELECT loc1.id, loc1.location_id, loc1.name
FROM stock_location loc1
WHERE id = 2024
UNION ALL
SELECT loc2.id, loc2.location_id, loc2.name
FROM stock_location loc2
INNER JOIN location_tree lt ON lt.id = loc2.location_id
) SELECT id
FROM location_tree
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment