From b0fb8bcfec6d144ef5afe7bfee7a16b82025d1d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Alix?= Date: Fri, 30 Jul 2021 15:30:40 +0200 Subject: [PATCH] [FIX] s_o_manual_procurement: handle NewId (fix) --- .../models/stock_warehouse_orderpoint.py | 13 ++++++++++++- 1 file changed, 12 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 81d8dc5d6..ee8e62981 100644 --- a/stock_orderpoint_manual_procurement/models/stock_warehouse_orderpoint.py +++ b/stock_orderpoint_manual_procurement/models/stock_warehouse_orderpoint.py @@ -41,8 +41,19 @@ class StockWarehouseOrderpoint(models.Model): @api.depends("product_min_qty", "product_id", "qty_multiple") def _compute_procure_recommended(self): - op_qtys = self._quantity_in_progress() + # '_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() for op in self: + if not op.id: + op.update( + { + "procure_recommended_qty": False, + "procure_recommended_date": False, + } + ) + continue qty = 0.0 virtual_qty = op.with_context( location=op.location_id.id