diff --git a/addons/stock_account/report/stock_history.py b/addons/stock_account/report/stock_history.py index 3e67dd1db8d..ccf150954dc 100644 --- a/addons/stock_account/report/stock_history.py +++ b/addons/stock_account/report/stock_history.py @@ -79,7 +79,7 @@ class StockHistory(models.Model): product_template_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, string_agg(DISTINCT serial_number, ', ' ORDER BY serial_number) AS serial_number FROM