Commit 11aa0af8 authored by Julien Muchembled's avatar Julien Muchembled

MovementGroup.getAveragePrice: fix possible ZeroDivisionError

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41892 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 1f6bf214
......@@ -404,8 +404,10 @@ class FakeMovement:
price_dict = self._getPriceDict()
if len(price_dict) == 1:
return price_dict.keys()[0]
return sum(price * quantity for price, quantity in price_dict.items()) / \
float(sum(price_dict.values()))
total_quantity = sum(price_dict.values())
return (total_quantity and
sum(price * quantity for price, quantity in price_dict.items())
/ float(total_quantity))
def getAddQuantity(self):
"""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment