On Change Width Margin: calculate cost when qty is not null

This commit is contained in:
resteve 2014-11-21 08:57:13 +01:00
parent 79b7016797
commit 4990265673
1 changed files with 4 additions and 2 deletions

View File

@ -109,8 +109,10 @@ class SaleLine:
return Decimal('0.0')
currency = self.sale.currency
if self.type == 'line':
cost = Decimal(str(self.quantity)) * (self.cost_price or
Decimal('0.0'))
if self.quantity and self.cost_price:
cost = Decimal(str(self.quantity)) * (self.cost_price)
else:
cost = Decimal('0.0')
self.amount = self.on_change_with_amount()
return Currency.round(currency, self.amount - cost)
elif self.type == 'subtotal':