sale line: get margin depends amount and operation if self.amount

This commit is contained in:
resteve 2013-10-03 11:55:55 +02:00
parent 0b86ed0ec3
commit 37e4bd85a3
1 changed files with 5 additions and 4 deletions

View File

@ -62,9 +62,9 @@ class SaleLine:
states={
'invisible': ~Eval('type').in_(['line', 'subtotal']),
'readonly': ~Eval('_parent_sale'),
}, on_change_with=['type', 'quantity', 'cost_price',
}, on_change_with=['type', 'quantity', 'cost_price', 'amount',
'unit_price', 'unit', '_parent_sale.currency'],
depends=['type']), 'get_margin')
depends=['type', 'amount']), 'get_margin')
def on_change_product(self):
if not self.product:
@ -76,8 +76,9 @@ class SaleLine:
def on_change_with_margin(self):
cost = Decimal(str(self.quantity or '0.0')) * \
(self.cost_price or Decimal('0.0'))
res = Decimal(self.amount-cost)
return res
if self.amount:
return Decimal(self.amount-cost)
return Decimal('0.0')
def get_margin(self, name):
'''