From 943e45ba3d2ac715bb275512b1b2b12e1d2b11eb Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Thu, 12 Jul 2018 17:00:01 +0200 Subject: [PATCH] [FIX] sale_stock: float division by zero In some case, qty_delivered can be equal to 0 opw:1863726 --- addons/sale_stock/models/account_invoice.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/sale_stock/models/account_invoice.py b/addons/sale_stock/models/account_invoice.py index 084ffbd3706..a6dccfbc01c 100644 --- a/addons/sale_stock/models/account_invoice.py +++ b/addons/sale_stock/models/account_invoice.py @@ -49,7 +49,8 @@ class AccountInvoiceLine(models.Model): qty_to_consider = invoiced_qty - qty_done qty_to_consider = min(qty_to_consider, quantity - qty_delivered) qty_delivered += qty_to_consider - average_price_unit = (average_price_unit * (qty_delivered - qty_to_consider) + move.price_unit * qty_to_consider) / qty_delivered + if qty_delivered: + average_price_unit = (average_price_unit * (qty_delivered - qty_to_consider) + move.price_unit * qty_to_consider) / qty_delivered if qty_delivered == quantity: break return average_price_unit