update level nurse

conv_bal
watcha.h 2015-03-03 23:53:31 +07:00
parent 45b5e932fa
commit 7d48d0b10d
6 changed files with 53 additions and 22 deletions

View File

@ -3,7 +3,7 @@
<field name="state"/>
<button string="Options" dropdown="1">
<item string="Copy" method="copy" states="active"/>
<item string="To Draft" method="to_draft" states="drop,active"/>
<item string="To Draft" method="to_draft" states="drop,active,expire"/>
</button>
</head>
<group span="6" columns="1">

View File

@ -3,9 +3,9 @@
<field name="date" span="2" mode="month" onchange="onchange_date"/>
<field name="date_from" span="2"/>
<field name="date_to" span="2"/>
<!--<field name="cycle_id" span="2"/>-->
<field name="branch_id" span="3" onchange="onchange_branch"/>
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="3"/>
<field name="cycle_id" span="2"/>
<field name="branch_id" span="2" onchange="onchange_branch"/>
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
<field name="lines" nolabel="1">
<list>
<field name="patient_id" onchange="onchange_patient"/>

View File

@ -139,7 +139,7 @@ class CycleItem(Model):
nurse_id=line['nurse_id']
nurse=get_model('clinic.staff').browse(nurse_id)
line['level_id']=nurse.level_id.id
line['categ_id']=nurse.categ_id.id
line['categ_id']=nurse.categ_id #XXX
return data
def view_schedule(self,ids,context={}):

View File

@ -55,9 +55,9 @@ class Patient(Model):
if obj.last_name:
name+=obj.last_name or ""
if not obj.active:
name+='not_use'
name+='__'
elif context.get('active'):
name+='not_use'
name+='__'
res[obj.id]={
'name': name,
'name_check': name.replace(" ",""), # remove all space for make sure

View File

@ -126,18 +126,46 @@ class ClinicSetting(Model):
if user_id !=1:
print("Only admin!!")
return
for pt in get_model("clinic.patient").search_browse([]):
dates=[]
print("="*50)
for visit in pt.visits:
if visit.state=='confirmed':
continue
if visit.visit_date in dates:
print(pt.name, ' delete ', visit.visit_date)
visit.to_draft()
visit.delete()
dates.append(visit.visit_date)
print("="*50)
for citem in get_model("clinic.cycle.item").search_browse([]):
for line in citem.lines:
nurse=line.nurse_id
categ_id=nurse.categ_id.id
level_id=nurse.level_id
line.write({
'categ_id': categ_id,
'level_id': level_id,
})
print("Done!")
return
# run below before above!
import csv
f=open("/tmp/update_rotation.csv","r")
rd=csv.reader(f)
headers=next(rd)
headers=[h.lower().replace(" ","") for h in headers]
lines=[]
for row in rd:
vals=dict(zip(headers,row))
lines.append(vals)
levels={}
for level in get_model("clinic.staff.level").search_read([]):
levels[level['name']]=level['id']
categories={}
for categ in get_model("clinic.staff.categ").search_read([]):
categories[categ['name']]=categ['id']
for line in lines:
db_id=int(line['databaseid'])
level=line['level']
level_id=levels.get(level,None)
catetory=line['category']
categ_id=categories.get(catetory,None)
rt=get_model('clinic.staff.rotation').browse(db_id)
rt.write({
'level_id': level_id,
'categ_id': categ_id,
})
#print(line)
print("Done!")
return

View File

@ -37,17 +37,20 @@ class Staff(Model):
max_cycle=0
ot_per_cycle=0
level_id=None
categ_id=None
for rotate in obj.rotations:
if rotate.state=='approved':
level_id=rotate.level_id.id
wage=rotate.wage
max_cycle=rotate.max_cycle
ot_per_cycle=rotate.ot_per_cycle or 0
categ_id=rotate.categ_id.id
res[obj.id]={
'wage': wage,
'max_cycle': max_cycle,
'ot_per_cycle': ot_per_cycle,
'level_id': level_id,
'categ_id': categ_id,
}
return res
@ -82,9 +85,9 @@ class Staff(Model):
if obj.last_name:
name+=obj.last_name or ""
if not obj.active:
name+='not_use'
name+='__'
elif context.get('active'):
name+='not_use'
name+='__'
res[obj.id]={
'name': name,
'name_check': name.replace(" ",""), # remove all space for make sure
@ -126,7 +129,7 @@ class Staff(Model):
"user_id": fields.Many2One("base.user","User",search=True),
'image': fields.File("Image"),
'note': fields.Text("Note"),
'categ_id': fields.Many2One("clinic.staff.categ", "Category",search=True),
'categ_id': fields.Many2One("clinic.staff.categ", "Category",function="_get_rotation",function_multi=True),
'level_id': fields.Many2One("clinic.staff.level", "Level", function="_get_rotation",function_multi=True),
'active': fields.Boolean("Active"),
'date': fields.Date("Register Date"),