option to compute realtime

conv_bal
watcha.h 2014-12-02 15:51:21 +07:00
parent b573442a1e
commit cf5f708559
5 changed files with 23 additions and 18 deletions

View File

@ -1,4 +1,4 @@
<form model="clinic.hd.case" attrs='{"readonly":[["state","in",["uncompleted","completed"]]]}' show_company="1">
<form model="clinic.hd.case" attrs='{"readonly":[["state","in",["cancelled","completed"]]]}' show_company="1">
<head>
<field name="state"/>
<button string="Options" dropdown="1">

View File

@ -2,7 +2,8 @@
<tabs>
<tab string="HD Case">
<group form_layout="stacked">
<field name="waiting_approval"/>
<field name="waiting_approval" span="3"/>
<field name="real_time" span="3"/>
<separator string="Expenes"/>
<field name="products" nolabel="1">
<list>

View File

@ -191,6 +191,11 @@ class HDCase(Model):
date=data['time_start'][0:10]
data['time_start']='%s %s'%(date, cycle.time_start)
data['time_stop']='%s %s'%(date, cycle.time_stop)
fmt="%Y-%m-%d %H:%M"
diff=datetime.strptime(data['time_stop'],fmt)-datetime.strptime(data['time_start'],fmt)
total_time=round(diff.seconds/3600,2)
data['duration']=total_time
#XXX get nurse team
return data
def onchange_patient(self,context={}):
@ -520,14 +525,17 @@ class HDCase(Model):
#TODO should find dlz when confirm visit
if not obj.dialyzers:
raise Exception("Please input dialyzer!")
# update start time
timenow=time.strftime("%H:%M:%S")
date=obj.date
vals={
'time_start': '%s %s'%(date,timenow),
'time_stop': '%s %s'%(date,timenow),
'state': 'in_progress',
}
# update start time
st=get_model("clinic.setting").browse(1)
if st.real_time:
timenow=time.strftime("%H:%M:%S")
date=obj.date
vals['time_start']='%s %s'%(date,timenow)
vals['time_stop']='%s %s'%(date,timenow)
obj.write(vals)
def discontinue(self,ids,context={}):
@ -573,12 +581,15 @@ class HDCase(Model):
obj.post_invoices()
obj.update_usetime()
obj.create_cycle_item()
timenow=time.strftime("%H:%M:%S")
date=obj.date
vals={
"state":"completed",
#'time_stop': '%s %s'%(date,timenow),
}
st=get_model("clinic.setting").browse(1)
if st.real_time:
timenow=time.strftime("%H:%M:%S")
date=obj.date
vals['time_stop']='%s %s'%(date,timenow)
st=get_model("clinic.setting").browse(1)
if st.waiting_approval:
vals['state']='waiting_approval'

View File

@ -1,5 +1,3 @@
import time
from netforce.model import Model, fields, get_model
class HDCasePayment(Model):
@ -55,10 +53,7 @@ class HDCasePayment(Model):
hd_case.make_payment(context=context)
if obj.complete:
hd_case.create_cycle_item()
date=hd_case.date
timenow=time.strftime("%H:%M:%S")
vals={
'time_stop': '%s %s'%(date,timenow),
'state': 'completed',
}
if st.waiting_approval:
@ -83,10 +78,7 @@ class HDCasePayment(Model):
hd_case.post_invoices()
hd_case.create_cycle_item()
st=get_model("clinic.setting").browse(1)
date=hd_case.date
timenow=time.strftime("%H:%M:%S")
vals={
'time_stop': '%s %s'%(date,timenow),
'state': 'completed',
}
if st.waiting_approval:

View File

@ -15,6 +15,7 @@ class ClinicSetting(Model):
'company_id': fields.Many2One("company", 'Company'),
'period_id': fields.Many2One("clinic.period","Period"),
'waiting_approval': fields.Boolean("Waiting Approval"),
'real_time': fields.Boolean("Real Time"),
}
_defaults={