From 5e466d3507d81db5fd698d18fe623e5b802bd011 Mon Sep 17 00:00:00 2001 From: Daniel-CA Date: Tue, 31 May 2016 17:55:27 +0200 Subject: [PATCH] [FIX] stock_account: prevent division by zero In case of a move where source location = destination location, the result of SUM(quantity) would be 0 and ending up with a division by zero. Closes #12247 Closes #12423 --- addons/stock_account/wizard/stock_valuation_history.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/stock_account/wizard/stock_valuation_history.py b/addons/stock_account/wizard/stock_valuation_history.py index d3a53b1046a..49e66d490ce 100644 --- a/addons/stock_account/wizard/stock_valuation_history.py +++ b/addons/stock_account/wizard/stock_valuation_history.py @@ -125,7 +125,7 @@ class stock_history(osv.osv): product_categ_id, SUM(quantity) as quantity, date, - SUM(price_unit_on_quant * quantity) / SUM(quantity) as price_unit_on_quant, + COALESCE(SUM(price_unit_on_quant * quantity) / NULLIF(SUM(quantity), 0), 0) as price_unit_on_quant, source FROM ((SELECT