conv_bal
watcha.h 2014-11-24 17:14:21 +07:00
parent 7326ac9da3
commit a13cc8797f
4 changed files with 18 additions and 2 deletions

View File

@ -15,8 +15,8 @@
<field name="personal_id"/>
<field name="level_id"/>
<field name="type"/>
<field name="qty"/>
<field name="rate"/>
<field name="qty" onchange="onchange_line"/>
<field name="rate" onchange="onchange_line"/>
<field name="amount"/>
</list>
<form>

View File

@ -2,6 +2,7 @@ import time
from netforce.model import Model, fields
from netforce.access import get_active_company, get_active_user
from netforce.utils import get_data_path
class CycleDialy(Model):
_name="clinic.cycle.dialy"
@ -94,4 +95,19 @@ class CycleDialy(Model):
'flash':'Draft!',
}
def onchange_line(self,context={}):
data=context['data']
path=context['path']
line=get_data_path(data,path,parent=True)
qty=line['qty']
rate=line['rate']
line['amount']=qty*rate
total=0.0
for line in data['lines']:
qty=line['qty']
rate=line['rate']
total+=qty*rate
data['total']=total
return data
CycleDialy.register()