PerformanceHighlight of Weekly #003

Replenishment report no longer scales cubically

Forecast quantities are now computed straight from quants and moves. The old version grew with locations × products × moves.

Versions19.020.0
ModulesInventory stock
AppInventory & Manufacturing

Pull requests and commits

BranchPull requestCommit
19.0odoo/odoo#293600 ↗3b567018e9 ↗
20.0odoo/odoo#294377 ↗ca7c41d2bc ↗

Commit message

[PERF] stock: speed up orderpoint action

Before this commit, calls to `is_parent_path_in` when forecasting
quantities scaled cubicly with locations x products x quants/moves. A
lot of work is also done on product locations with an existing
orderpoint, all to be discarded at the end. The line
`orderpoint.qty_forecast += product_qty` has no tangible effect since
the field is non-stored with no inverse.

This commit lifts the quantity computation to be directly from the
quants/moves data, and stores the result in a dictionary to be accessed
later. This also elminates the need for uom float comparisons for
products without quants/moves.

This commit also removes all unnecessary intermediate steps for product
locations which already have an orderpoint.

This commit also applies other trivial optimzations:
- Remove intermediate recordset when calling
  `_unlink_processed_orderpoints`
- Order by id on searches where the default order is not needed.

Benchmarks
---
+-----------------------------+------------+---------------+
| Scenario                    | Total Time | Total Queries |
+-----------------------------+------------+---------------+
| 18      Replenish Locations | 17s        | 1,175         |
| 31,000  Replenish Products  |            |               |
| 141,000 Quants              | After:     | After:        |
| 14,000  Moves               | 3.64s      | 634           |
| 472,000 Orderpoints         |            |               |
+-----------------------------+------------+---------------+
| 35      Replenish Locations | 389s       | >50,000       |
| 89,000  Replenish Products  |            |               |
| 298,000 Quants              | After:     | After:        |
| 539,000 Moves               | 19s        | 1,068         |
| 634,000 Orderpoints         |            |               |
+-----------------------------+------------+---------------+

opw-6357118

My stack

Pick the versions and apps you run. Weekly digests, this week's table and All changes then show only what concerns you. Saved in this browser.

Versions
Apps
Modules