[FIX] stock: improve perf of _compute_has_packages of stock.picking
When a picking contains a lot (> 10000) of stock move line, the time to open the picking become a issue (for 50000 sml, +- 6.5 sec) because of the `_compute_has_packages`. Use a search with a limit=1 to avoid fetching all `stock.move.line` with `result_package_id` (for 50000 sml, +- 2.5 sec). opw-2371161 X-original-commit: e78ca55997dfbf13c0798c1f59408450071e1452
This commit is contained in:
@@ -527,7 +527,7 @@ class Picking(models.Model):
|
||||
|
||||
def _compute_has_packages(self):
|
||||
for picking in self:
|
||||
picking.has_packages = picking.move_line_ids.filtered(lambda ml: ml.result_package_id)
|
||||
picking.has_packages = bool(self.env['stock.move.line'].search_count([('picking_id', '=', picking.id), ('result_package_id', '!=', False)]))
|
||||
|
||||
@api.depends('immediate_transfer', 'state')
|
||||
def _compute_show_check_availability(self):
|
||||
|
||||
Reference in New Issue
Block a user