update level nurse
parent
45b5e932fa
commit
7d48d0b10d
|
@ -3,7 +3,7 @@
|
||||||
<field name="state"/>
|
<field name="state"/>
|
||||||
<button string="Options" dropdown="1">
|
<button string="Options" dropdown="1">
|
||||||
<item string="Copy" method="copy" states="active"/>
|
<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>
|
</button>
|
||||||
</head>
|
</head>
|
||||||
<group span="6" columns="1">
|
<group span="6" columns="1">
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
<field name="date" span="2" mode="month" onchange="onchange_date"/>
|
<field name="date" span="2" mode="month" onchange="onchange_date"/>
|
||||||
<field name="date_from" span="2"/>
|
<field name="date_from" span="2"/>
|
||||||
<field name="date_to" span="2"/>
|
<field name="date_to" span="2"/>
|
||||||
<!--<field name="cycle_id" span="2"/>-->
|
<field name="cycle_id" span="2"/>
|
||||||
<field name="branch_id" span="3" onchange="onchange_branch"/>
|
<field name="branch_id" span="2" onchange="onchange_branch"/>
|
||||||
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="3"/>
|
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
|
||||||
<field name="lines" nolabel="1">
|
<field name="lines" nolabel="1">
|
||||||
<list>
|
<list>
|
||||||
<field name="patient_id" onchange="onchange_patient"/>
|
<field name="patient_id" onchange="onchange_patient"/>
|
||||||
|
|
|
@ -139,7 +139,7 @@ class CycleItem(Model):
|
||||||
nurse_id=line['nurse_id']
|
nurse_id=line['nurse_id']
|
||||||
nurse=get_model('clinic.staff').browse(nurse_id)
|
nurse=get_model('clinic.staff').browse(nurse_id)
|
||||||
line['level_id']=nurse.level_id.id
|
line['level_id']=nurse.level_id.id
|
||||||
line['categ_id']=nurse.categ_id.id
|
line['categ_id']=nurse.categ_id #XXX
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def view_schedule(self,ids,context={}):
|
def view_schedule(self,ids,context={}):
|
||||||
|
|
|
@ -55,9 +55,9 @@ class Patient(Model):
|
||||||
if obj.last_name:
|
if obj.last_name:
|
||||||
name+=obj.last_name or ""
|
name+=obj.last_name or ""
|
||||||
if not obj.active:
|
if not obj.active:
|
||||||
name+='not_use'
|
name+='__'
|
||||||
elif context.get('active'):
|
elif context.get('active'):
|
||||||
name+='not_use'
|
name+='__'
|
||||||
res[obj.id]={
|
res[obj.id]={
|
||||||
'name': name,
|
'name': name,
|
||||||
'name_check': name.replace(" ",""), # remove all space for make sure
|
'name_check': name.replace(" ",""), # remove all space for make sure
|
||||||
|
|
|
@ -126,18 +126,46 @@ class ClinicSetting(Model):
|
||||||
if user_id !=1:
|
if user_id !=1:
|
||||||
print("Only admin!!")
|
print("Only admin!!")
|
||||||
return
|
return
|
||||||
for pt in get_model("clinic.patient").search_browse([]):
|
for citem in get_model("clinic.cycle.item").search_browse([]):
|
||||||
dates=[]
|
for line in citem.lines:
|
||||||
print("="*50)
|
nurse=line.nurse_id
|
||||||
for visit in pt.visits:
|
categ_id=nurse.categ_id.id
|
||||||
if visit.state=='confirmed':
|
level_id=nurse.level_id
|
||||||
continue
|
line.write({
|
||||||
if visit.visit_date in dates:
|
'categ_id': categ_id,
|
||||||
print(pt.name, ' delete ', visit.visit_date)
|
'level_id': level_id,
|
||||||
visit.to_draft()
|
})
|
||||||
visit.delete()
|
print("Done!")
|
||||||
dates.append(visit.visit_date)
|
return
|
||||||
print("="*50)
|
# 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!")
|
print("Done!")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -37,17 +37,20 @@ class Staff(Model):
|
||||||
max_cycle=0
|
max_cycle=0
|
||||||
ot_per_cycle=0
|
ot_per_cycle=0
|
||||||
level_id=None
|
level_id=None
|
||||||
|
categ_id=None
|
||||||
for rotate in obj.rotations:
|
for rotate in obj.rotations:
|
||||||
if rotate.state=='approved':
|
if rotate.state=='approved':
|
||||||
level_id=rotate.level_id.id
|
level_id=rotate.level_id.id
|
||||||
wage=rotate.wage
|
wage=rotate.wage
|
||||||
max_cycle=rotate.max_cycle
|
max_cycle=rotate.max_cycle
|
||||||
ot_per_cycle=rotate.ot_per_cycle or 0
|
ot_per_cycle=rotate.ot_per_cycle or 0
|
||||||
|
categ_id=rotate.categ_id.id
|
||||||
res[obj.id]={
|
res[obj.id]={
|
||||||
'wage': wage,
|
'wage': wage,
|
||||||
'max_cycle': max_cycle,
|
'max_cycle': max_cycle,
|
||||||
'ot_per_cycle': ot_per_cycle,
|
'ot_per_cycle': ot_per_cycle,
|
||||||
'level_id': level_id,
|
'level_id': level_id,
|
||||||
|
'categ_id': categ_id,
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
@ -82,9 +85,9 @@ class Staff(Model):
|
||||||
if obj.last_name:
|
if obj.last_name:
|
||||||
name+=obj.last_name or ""
|
name+=obj.last_name or ""
|
||||||
if not obj.active:
|
if not obj.active:
|
||||||
name+='not_use'
|
name+='__'
|
||||||
elif context.get('active'):
|
elif context.get('active'):
|
||||||
name+='not_use'
|
name+='__'
|
||||||
res[obj.id]={
|
res[obj.id]={
|
||||||
'name': name,
|
'name': name,
|
||||||
'name_check': name.replace(" ",""), # remove all space for make sure
|
'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),
|
"user_id": fields.Many2One("base.user","User",search=True),
|
||||||
'image': fields.File("Image"),
|
'image': fields.File("Image"),
|
||||||
'note': fields.Text("Note"),
|
'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),
|
'level_id': fields.Many2One("clinic.staff.level", "Level", function="_get_rotation",function_multi=True),
|
||||||
'active': fields.Boolean("Active"),
|
'active': fields.Boolean("Active"),
|
||||||
'date': fields.Date("Register Date"),
|
'date': fields.Date("Register Date"),
|
||||||
|
|
Loading…
Reference in New Issue