From 913d1572e320402618c30aafe29134001c3961e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Alix?= Date: Thu, 7 Apr 2022 16:08:29 +0200 Subject: [PATCH] [FIX] s_o_manual_procurement: fix heavy request if no orderpoint --- .../models/stock_warehouse_orderpoint.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/stock_orderpoint_manual_procurement/models/stock_warehouse_orderpoint.py b/stock_orderpoint_manual_procurement/models/stock_warehouse_orderpoint.py index 921bd1edc..b659f7190 100644 --- a/stock_orderpoint_manual_procurement/models/stock_warehouse_orderpoint.py +++ b/stock_orderpoint_manual_procurement/models/stock_warehouse_orderpoint.py @@ -43,7 +43,14 @@ class StockWarehouseOrderpoint(models.Model): # '_quantity_in_progress' override in 'purchase_stock' method has not # been designed to work with NewIds (resulting in KeyError exceptions). # To circumvent this, we knowingly skip such records here. - op_qtys = self.filtered(lambda x: x.id)._quantity_in_progress() + ops = self.filtered("id") + op_qtys = {} + # No need to call '_quantity_in_progress()' if there is no orderpoint, + # this leads to a heavy request done by a call to `read_group` with + # an empty domain on 'purchase.order.line' in the + # 'product.product._get_quantity_in_progress()' method. + if ops: + op_qtys = ops._quantity_in_progress() for op in self: if not op.id: op.update(