[FIX] sale: sometimes an invoiced quantity could be 0, need to avoid divide by 0 error

This commit is contained in:
Damien Bouvy
2015-09-25 10:33:47 +02:00
parent 144b4f8098
commit 15d2778f0f
+2
View File
@@ -39,6 +39,8 @@ class AccountAnalyticLine(models.Model):
so_line = fields.Many2one('sale.order.line', string='Sale Order Line')
def _get_invoice_price(self, order):
if self.unit_amount == 0.0:
return 0.0
price_unit = abs(self.amount / self.unit_amount)
if self.currency_id and self.currency_id != order.currency_id:
price_unit = self.currency_id.compute(price_unit, order.currency_id)