prevent forgot enter doctor in hdcase

conv_bal
watcha.h 2015-04-24 13:48:11 +07:00
parent c68c521922
commit b79cfd015e
2 changed files with 22 additions and 2 deletions

View File

@ -99,7 +99,7 @@
<field name="staffs" nolabel="1">
<list>
<!--<field name="type" invisible="1"/>-->
<field name="staff_id" domain="[['type','=','doctor']]"/>
<field name="staff_id" onchange="onchange_staff" domain="[['type','=','doctor']]"/>
<field name="priop"/>
<field name="note"/>
</list>

View File

@ -101,6 +101,7 @@ class HDCase(Model):
lab=0
misc=0
dlz_price=0
srv=0
mdc=0
for line in obj.lines:
amt=line.amount or 0
@ -122,7 +123,6 @@ class HDCase(Model):
else:
mdc+=amt
mdc_names.append(name or "")
continue #XXX
if categ.code=='EPO':
name=prod.name or ""
name=name.split("-")
@ -133,6 +133,8 @@ class HDCase(Model):
fee+=amt*sign
elif categ.code=='DLZ':
dlz_price+=amt
elif categ.code=='SRV':
dlz_price+=amt
elif categ.code=="LAB":
if reimbursable_ctx:
if reimbursable_ctx==line.reimbursable:
@ -151,6 +153,7 @@ class HDCase(Model):
'lab': lab,
'misc': misc,
'mdc': mdc,
'srv': srv,
'mdc_name': ','.join([n for n in mdc_names]),
'dlz_id': dlz_id,
'dlz_price': dlz_price,
@ -207,6 +210,7 @@ class HDCase(Model):
"dlz_max": fields.Float("DZ Max",function="_get_expense",function_multi=True),
"dlz_id": fields.Integer("DZ ID",function="_get_expense",function_multi=True),
"mdc": fields.Float("MDC",function="_get_expense",function_multi=True),
"srv": fields.Float("Service",function="_get_expense",function_multi=True),
"mdc_name": fields.Float("MDC Name",function="_get_expense",function_multi=True),
'sickbed_id': fields.Many2One("clinic.sickbed",'Sickbed'),
"ref": fields.Char("Ref",search=True),
@ -1084,6 +1088,12 @@ class HDCase(Model):
def done(self,ids,context={}):
obj=self.browse(ids)[0]
count=0
for sline in obj.staffs:
if sline.staff_id:
count+=1
if not count:
raise Exception("Please define doctor for patient %s"%obj.patient_id.name)
obj.update_usetime()
#FIXME allow user to write sickbed status
user_id=get_active_user()
@ -1486,6 +1496,8 @@ class HDCase(Model):
st[staff.id]=1
else:
raise Exception("Douplicate %s"%staff.name)
if not st:
raise Exception("Please define doctor!")
self.check_hct(obj)
def approve(self,ids,context={}):
@ -1557,5 +1569,13 @@ class HDCase(Model):
},
'flash': '%s is droped'%dlz.number,
}
def onchange_staff(self,context={}):
data=context['data']
path=context['path']
line=get_data_path(data,path,parent=True)
if not line.get('priop'):
line['priop']='owner'
return data
HDCase.register()