Skip to content

Instantly share code, notes, and snippets.

View grindtildeath's full-sized avatar

Akim Juillerat grindtildeath

View GitHub Profile
@grindtildeath
grindtildeath / odoo_module_dependency_graph.sql
Last active August 18, 2022 14:21
Odoo module dependency graph
WITH recursive dep_tree AS (
SELECT mdl0.id, mdl0.name, NULL::integer, 1 AS level, array[mdl0.id] AS path_info
FROM ir_module_module mdl0
WHERE name = 'sale' -- state here the child module
UNION ALL
SELECT (SELECT mdl1.id FROM ir_module_module mdl1 WHERE mdl1.name = c.name), rpad('', p.level * 1, '_') || c.name, c.module_id, p.level + 1, p.path_info||c.id
FROM ir_module_module_dependency c
JOIN dep_tree p ON c.module_id = p.id
WHERE level < 5 -- define here the levels to be displayed
)
@grindtildeath
grindtildeath / gist:d0618f2f8170ebb5e1618a0e814edce4
Created November 5, 2018 15:42
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
@grindtildeath
grindtildeath / get_recipient_data_query_plans.txt
Last active June 1, 2022 08:55
Odoo mail.followers._get_recipient_data query plans
Before:
|QUERY PLAN |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|Unique (cost=54330961.69..54429026.37 rows=40000 width=106) (actual time=7771.241..7771.241 rows=1 loops=1) |
| -> Sort (cost=54330961.69..54363649.92 rows=13075291 width=106) (actual time=7771.240..7771.240 rows=1 loops=1) |
| Sort Key: partner.id, (NULL::integer), users.notification_type
@grindtildeath
grindtildeath / profile__search_product_qty.log
Created September 30, 2022 08:34
Profile _search_product_qty v14.0 on 33031 records
2022-09-30 08:27:32,167 1 INFO zhinst_lab odoo.tools.profiler:
calls queries ms
stock.production.lot --------------------- /odoo/external-src/stock-logistics-workflow/stock_lot_product_qty_search/models/stock_production_lot.py, 17
1 0 0.05 @profile
def _search_product_qty(self, operator, value):
1 0 0.04 if operator not in ("<", ">", "=", "!=", "<=", ">="):
raise UserError(_("Invalid domain operator %s", operator))
1 0 0.03 if not isinstance(value, (float, int)):
raise UserError(_("Invalid domain right operand %s", value))