Replenishment report no longer scales cubically
Forecast quantities are now computed straight from quants and moves. The old version grew with locations × products × moves.
Forecast quantities are now computed straight from quants and moves. The old version grew with locations × products × moves.
| Branch | Pull request | Commit |
|---|---|---|
| 19.0 | odoo/odoo#293600 ↗ | 3b567018e9 ↗ |
| 20.0 | odoo/odoo#294377 ↗ | ca7c41d2bc ↗ |
[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