diff options
| author | Simon Lejeune <sle@openerp.com> | 2018-01-05 16:32:46 +0100 |
|---|---|---|
| committer | Simon Lejeune <sle@openerp.com> | 2018-01-05 18:28:32 +0100 |
| commit | 25943696ea00b140ea19de1c6ee6a42d97d8e2f7 (patch) | |
| tree | 653237021e14496004e20be94a1d40d6036f8293 | |
| parent | d4982394bc9cf2b330e7c87bd7b8d1cae74ffb5f (diff) | |
[FIX] stock: _compute_entire_package_ids
When a picking contain a few thousands move line, reading it was slow
because of the computation of "entire_package_ids" and
"entire_package_detail_ids". The compute method for this field calls
"_check_move_lines_map_quant_package" that check that, for a picking,
all the move lines having "package_id" and "result_package_id" as the
same package (ie moving an entire pack) match exactly the content of the
package (ie the quants).
The issue was that the method was called for every move line without
packaging because of a wrongly written condition. We now only call the
method one time for each package, whatever the number of move line.
opw-803887
| -rw-r--r-- | addons/stock/models/stock_picking.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py index 213c54a4c7a..71fd5cb3d69 100644 --- a/addons/stock/models/stock_picking.py +++ b/addons/stock/models/stock_picking.py @@ -405,10 +405,12 @@ class Picking(models.Model): """ for picking in self: packages = self.env['stock.quant.package'] - for ml in picking.move_line_ids: - if ml.package_id.id == ml.result_package_id.id: - if picking.state in ('done', 'cancel') or picking._check_move_lines_map_quant_package(ml.package_id): - packages |= ml.package_id + packages_to_check = picking.move_line_ids\ + .filtered(lambda ml: ml.result_package_id and ml.package_id.id == ml.result_package_id.id)\ + .mapped('package_id') + for package_to_check in packages_to_check: + if picking.state in ('done', 'cancel') or picking._check_move_lines_map_quant_package(package_to_check): + packages |= package_to_check picking.entire_package_ids = packages picking.entire_package_detail_ids = packages |
