From 49902656735ce9d1a89a31569fca3ef8818693fb Mon Sep 17 00:00:00 2001 From: resteve Date: Fri, 21 Nov 2014 08:57:13 +0100 Subject: [PATCH] On Change Width Margin: calculate cost when qty is not null --- sale.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sale.py b/sale.py index 9bc2be9..0ea7939 100644 --- a/sale.py +++ b/sale.py @@ -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':