Skip to content
Snippets Groups Projects
Commit 23ef75f9 authored by Aurelien van Delft (avd)'s avatar Aurelien van Delft (avd)
Browse files

[FIX] delivery: read_group fest speeding up weights compute


Currently _compute_bulk_weight and _compute_weight are
going through each picking in self and each stock_move_line
in picking.move_line_ids to compute the pickings' weight.

This can be slow when there are lots of move_lines by pickings
as the field cache will be filled by the move_lines records
and uom._compute_quantity will be called once by move_line.

This is especially true for pickings with SN-tracked products.
For SN tracked products there will be one move_line by product_qty
(so a picking with 1 SN tracked product with a qty of 100 will have
 100 move_lines). In this case doing a read_group yields the highest
speedup.

Following the same reasoning a search_count is done in _compute_packages
before retrieving package.move_line_ids.
When package.move_line_ids.result_package_id is empty doing a count
is much faster as it avoids calling _in_cache_without for the package
move_line_ids. The search_count overhead is negligeable in the other
case so adding it leads to an overall speedup on average.

opw-3017013

closes odoo/odoo#107868

X-original-commit: ccac6fce
Signed-off-by: default avatarWilliam Henrotin (whe) <whe@odoo.com>
parent 0860ba85
Branches
Tags
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment