From 62adaa783cb2c43346ba290cf701eebe833faa99 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Tue, 9 Jun 2020 09:14:43 +0000 Subject: [PATCH] [FIX] Ignore sale order lines without product_id In some conditions, such as the use case shown on: https://github.com/guewen/odoo-reproduce-issues/blob/compute-qty-at-date/compute_qty_at_date/models/sale_order_line.py The order of the computations can make that we have a line without product_id (we come from an onchange because we removed the product form the line), but 'display_qty_widget' is not yet recomputed. Not checking if we have a product_id means we can end up with 'grouped_lines' that contains an entry for the line, but then 'product_qties' does not contain the product the dict comprehension that builds the dictionary 'qties_per_product' fails with a KeyError. opw-2273768 closes odoo/odoo#56406 X-original-commit: 9060b347949d11880c554468f551d25e874590d1 Signed-off-by: Simon Goffin (sig) --- addons/sale_stock/models/sale_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sale_stock/models/sale_order.py b/addons/sale_stock/models/sale_order.py index 495a691061e..86fcf8150bc 100644 --- a/addons/sale_stock/models/sale_order.py +++ b/addons/sale_stock/models/sale_order.py @@ -299,7 +299,7 @@ class SaleOrderLine(models.Model): # We first loop over the SO lines to group them by warehouse and schedule # date in order to batch the read of the quantities computed field. for line in self: - if not line.display_qty_widget: + if not (line.product_id and line.display_qty_widget): continue if line.order_id.commitment_date: date = line.order_id.commitment_date