conv_bal
parent
97c90ac975
commit
b74735980e
|
@ -16,6 +16,20 @@
|
||||||
</list>
|
</list>
|
||||||
</field>
|
</field>
|
||||||
</tab>
|
</tab>
|
||||||
|
<tab string="Labor Cost">
|
||||||
|
<group form_layout="stacked">
|
||||||
|
<field name="var_k" span="3"/>
|
||||||
|
<field name="var_pt" span="3"/>
|
||||||
|
<field name="var_ptx" span="3"/>
|
||||||
|
<field name="var_x" span="3"/>
|
||||||
|
<field name="lines" nolabel="1">
|
||||||
|
<list>
|
||||||
|
<field name="level_id"/>
|
||||||
|
<field name="qty"/>
|
||||||
|
</list>
|
||||||
|
</field>
|
||||||
|
</group>
|
||||||
|
</tab>
|
||||||
<tab string="Other Info">
|
<tab string="Other Info">
|
||||||
<field name="cycle_dialy_id" domain="[['date','=',date]]"/>
|
<field name="cycle_dialy_id" domain="[['date','=',date]]"/>
|
||||||
</tab>
|
</tab>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<list model="clinic.cycle.item" colors='{"#9f9":[["state","=","done"]]}'>
|
<list model="clinic.cycle.item" colors='{"#9f9":[["state","=","done"]]}'>
|
||||||
<field name="name"/>
|
<!--<field name="name"/>-->
|
||||||
<field name="cycle_id"/>
|
<field name="cycle_id"/>
|
||||||
<field name="date"/>
|
<field name="date"/>
|
||||||
<field name="state"/>
|
<field name="state"/>
|
||||||
|
|
|
@ -31,8 +31,8 @@
|
||||||
<field name="age"/>
|
<field name="age"/>
|
||||||
<field name="active"/>
|
<field name="active"/>
|
||||||
</group>
|
</group>
|
||||||
<separator string="Address Information"/>
|
<!--<separator string="Address Information"/>-->
|
||||||
<field name="addresses" view="form_list"/>
|
<!--<field name="addresses" view="form_list"/>-->
|
||||||
</tab>
|
</tab>
|
||||||
<tab string="Professional Information">
|
<tab string="Professional Information">
|
||||||
<field name="prof_license" attrs='{"invisible":[["type","in",["personal"]]]}'/>
|
<field name="prof_license" attrs='{"invisible":[["type","in",["personal"]]]}'/>
|
||||||
|
@ -47,6 +47,7 @@
|
||||||
</tabs>
|
</tabs>
|
||||||
<related>
|
<related>
|
||||||
<field name="documents"/>
|
<field name="documents"/>
|
||||||
|
<field name="addresses"/>
|
||||||
<field name="cycles" nolabel="1">
|
<field name="cycles" nolabel="1">
|
||||||
<list>
|
<list>
|
||||||
<field name="cycle_id"/>
|
<field name="cycle_id"/>
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
<form model="clinic.personal.level">
|
<form model="clinic.personal.level">
|
||||||
|
<head>
|
||||||
|
<button string="Options" dropdown="1">
|
||||||
|
<item string="Copy" method="copy"/>
|
||||||
|
</button>
|
||||||
|
</head>
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="type"/>
|
<field name="type"/>
|
||||||
<field name="formular"/>
|
|
||||||
<field name="sequence"/>
|
<field name="sequence"/>
|
||||||
<field name="description"/>
|
<field name="description"/>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<list model="clinic.personal.level">
|
<list model="clinic.personal.level">
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="type"/>
|
<field name="type"/>
|
||||||
<field name="formular"/>
|
<!--<field name="formular"/>-->
|
||||||
<field name="description"/>
|
<field name="description"/>
|
||||||
<field name="sequence"/>
|
<field name="sequence"/>
|
||||||
</list>
|
</list>
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
<list>
|
<list>
|
||||||
<field name="cycle_id"/>
|
<field name="cycle_id"/>
|
||||||
<field name="nurse_id"/>
|
<field name="nurse_id"/>
|
||||||
|
<field name="level_id"/>
|
||||||
</list>
|
</list>
|
||||||
</field>
|
</field>
|
||||||
</group>
|
</group>
|
||||||
|
|
|
@ -1,17 +1,39 @@
|
||||||
<form model="clinic.setting" title="Clinic Settings">
|
<form model="clinic.setting" title="Clinic Settings">
|
||||||
<tabs>
|
<tabs>
|
||||||
<tab string="Testing">
|
<tab string="Labor Cost">
|
||||||
<field name="file"/>
|
|
||||||
<newline/>
|
|
||||||
</tab>
|
|
||||||
<tab string="General">
|
|
||||||
<separator string="Labor Cost"/>
|
|
||||||
<field name="var_k"/>
|
<field name="var_k"/>
|
||||||
|
<field name="levels" nolabel="1">
|
||||||
|
<list>
|
||||||
|
<field name="level_id"/>
|
||||||
|
<field name="var_a"/>
|
||||||
|
<field name="op"/>
|
||||||
|
<field name="var_b"/>
|
||||||
|
<field name="formular"/>
|
||||||
|
</list>
|
||||||
|
<form>
|
||||||
|
<field name="level_id"/>
|
||||||
|
<field name="var_a"/>
|
||||||
|
<field name="op"/>
|
||||||
|
<field name="var_b"/>
|
||||||
|
<field name="formular"/>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
<html span="5" offset="1">
|
||||||
|
<h5 style="color:#666">How labor cost affect</h5>
|
||||||
|
</html>
|
||||||
|
</tab>
|
||||||
|
<tab string="Testing">
|
||||||
|
<group form_layout="stacked">
|
||||||
|
<field name="file" span="3"/>
|
||||||
|
<newline/>
|
||||||
|
<button string="Make Visit" method="make_visit" span="2"/>
|
||||||
|
<newline/>
|
||||||
|
<button string="Make HD Case" method="make_done" span="2"/>
|
||||||
|
<newline/>
|
||||||
|
<button string="Complete HD Case" method="make_complete" span="2"/>
|
||||||
|
</group>
|
||||||
</tab>
|
</tab>
|
||||||
</tabs>
|
</tabs>
|
||||||
<foot>
|
<foot>
|
||||||
<button string="Make Visit" method="make_visit"/>
|
|
||||||
<button string="Make HD Case" method="make_done"/>
|
|
||||||
<button string="Complete HD Case" method="make_complete"/>
|
|
||||||
</foot>
|
</foot>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
from . import utils
|
from . import utils
|
||||||
from . import setting
|
from . import setting
|
||||||
|
from . import setting_level
|
||||||
from . import cause_chronic
|
from . import cause_chronic
|
||||||
from . import comorbidity
|
from . import comorbidity
|
||||||
from . import department
|
from . import department
|
||||||
|
|
|
@ -5,7 +5,7 @@ from netforce.access import get_active_company
|
||||||
|
|
||||||
class CycleDialy(Model):
|
class CycleDialy(Model):
|
||||||
_name="clinic.cycle.dialy"
|
_name="clinic.cycle.dialy"
|
||||||
_string="Cycle Diay"
|
_string="Cycle Dialy"
|
||||||
|
|
||||||
_fields={
|
_fields={
|
||||||
"name": fields.Char("Name"),
|
"name": fields.Char("Name"),
|
||||||
|
|
|
@ -8,7 +8,7 @@ class CycleItem(Model):
|
||||||
_string="Cycle Item"
|
_string="Cycle Item"
|
||||||
_name_field="name"
|
_name_field="name"
|
||||||
|
|
||||||
def _get_all(self,ids,context):
|
def _get_all(self,ids,context={}):
|
||||||
res={}
|
res={}
|
||||||
for obj in self.browse(ids):
|
for obj in self.browse(ids):
|
||||||
name="%s-%s"%(obj.cycle_id.name,obj.date)
|
name="%s-%s"%(obj.cycle_id.name,obj.date)
|
||||||
|
@ -17,23 +17,43 @@ class CycleItem(Model):
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
def _get_pt(self,ids,context={}):
|
||||||
|
res={}
|
||||||
|
for obj in self.browse(ids):
|
||||||
|
total_case=len(obj.hd_cases)
|
||||||
|
res[obj.id]={
|
||||||
|
'var_pt': total_case,
|
||||||
|
'var_ptx': total_case*(obj.var_k or 0)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
|
||||||
_fields={
|
_fields={
|
||||||
'name': fields.Char("Name", function="_get_all",function_multi=True),
|
'name': fields.Char("Name", function="_get_all",function_multi=True),
|
||||||
'date': fields.Date("Date",search=True),
|
'date': fields.Date("Date",search=True),
|
||||||
'cycle_id': fields.Many2One("clinic.cycle", "Cycle",search=True),
|
'cycle_id': fields.Many2One("clinic.cycle", "Cycle",search=True),
|
||||||
'cycle_dialy_id': fields.Many2One("clinic.cycle.dialy", "Cycle Dialy",search=True),
|
'cycle_dialy_id': fields.Many2One("clinic.cycle.dialy", "Cycle Dialy",search=True),
|
||||||
|
'lines': fields.One2Many("clinic.cycle.item.line","item_id", "Lines"),
|
||||||
'visits': fields.One2Many("clinic.visit","cycle_item_id", "Visits"),
|
'visits': fields.One2Many("clinic.visit","cycle_item_id", "Visits"),
|
||||||
'hd_cases': fields.One2Many("clinic.hd.case","cycle_item_id", "HD Cases"),
|
'hd_cases': fields.One2Many("clinic.hd.case","cycle_item_id", "HD Cases"),
|
||||||
'nurses': fields.One2Many("clinic.cycle.item.nurse",'cycle_item_id','Nurses'),
|
'nurses': fields.One2Many("clinic.cycle.item.nurse",'cycle_item_id','Nurses'),
|
||||||
'sequence': fields.Char("Sequence"), # for sort item
|
'sequence': fields.Char("Sequence"), # for sort item
|
||||||
'company_id': fields.Many2One("company", "Company"),
|
'company_id': fields.Many2One("company", "Company"),
|
||||||
"state": fields.Selection([("draft","Draft"),("done","Done")],"Status",required=True),
|
"state": fields.Selection([("draft","Draft"),("done","Done")],"Status",required=True),
|
||||||
|
'var_k': fields.Float("K"),
|
||||||
|
'var_x': fields.Float("X"),
|
||||||
|
'var_pt': fields.Integer("PT", function="_get_pt",function_multi=True),
|
||||||
|
'var_ptx': fields.Float("PT x K", function="_get_pt",function_multi=True),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def _get_vark(self,context={}):
|
||||||
|
st=get_model("clinic.setting").browse(1)
|
||||||
|
return st.var_k or 0
|
||||||
|
|
||||||
_defaults={
|
_defaults={
|
||||||
'state': 'draft',
|
'state': 'draft',
|
||||||
'company_id': lambda *a: get_active_company(),
|
'company_id': lambda *a: get_active_company(),
|
||||||
'date': lambda *a: time.strftime("%Y-%m-%d"),
|
'date': lambda *a: time.strftime("%Y-%m-%d"),
|
||||||
|
'var_k': _get_vark,
|
||||||
}
|
}
|
||||||
|
|
||||||
_order="sequence"
|
_order="sequence"
|
||||||
|
|
|
@ -14,14 +14,11 @@ class CycleItemLine(Model):
|
||||||
return res
|
return res
|
||||||
|
|
||||||
_fields={
|
_fields={
|
||||||
'cycle_item_id': fields.Many2One("clinic.cycle.item", "Cycle Item"),
|
'item_id': fields.Many2One("clinic.cycle.item", "Cycle Item"),
|
||||||
"type": fields.Selection([("doctor","Doctor"),("nurse","Nurse")],"Personal Type",required=True),
|
'level_id': fields.Many2One("clinic.personal.level", "Level",domain=[['type','=','nurse']]),
|
||||||
'personal_categ': fields.Many2One("clinic.personal.categ", "Nurse Category",),
|
|
||||||
'formular': fields.Char("Formular", size=100),
|
'formular': fields.Char("Formular", size=100),
|
||||||
'description': fields.Char("Description"),
|
|
||||||
'qty': fields.Integer("Qty"),
|
'qty': fields.Integer("Qty"),
|
||||||
'rate': fields.Float("Rate"),
|
'rate': fields.Float("Rate"),
|
||||||
#'amount': fields.Float("Amount",function="all_amount", function_multi=True),
|
|
||||||
'amount': fields.Float("Amount"),
|
'amount': fields.Float("Amount"),
|
||||||
'company_id': fields.Many2One('company','Company'),
|
'company_id': fields.Many2One('company','Company'),
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,9 +71,24 @@ class GenVisit(Model):
|
||||||
'nurse_id': _get_nurse,
|
'nurse_id': _get_nurse,
|
||||||
'duration': 1,
|
'duration': 1,
|
||||||
'cycle_id': _get_cycle,
|
'cycle_id': _get_cycle,
|
||||||
'monday': True,
|
#'monday': True, # dynamic select weekday, use default_get
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def default_get(self,field_names=None,context=None,**kw):
|
||||||
|
vals=super().default_get(field_names,context,**kw)
|
||||||
|
wd=datetime.now().weekday()
|
||||||
|
wds={
|
||||||
|
0: 'monday',
|
||||||
|
1: 'tuesday',
|
||||||
|
2: 'wednesday',
|
||||||
|
3: 'thursday',
|
||||||
|
4: 'friday',
|
||||||
|
5: 'sathurday',
|
||||||
|
6: 'sunday',
|
||||||
|
}
|
||||||
|
vals[wds[wd]]=True
|
||||||
|
return vals
|
||||||
|
|
||||||
def onchange_time(self,context={}):
|
def onchange_time(self,context={}):
|
||||||
data=context['data']
|
data=context['data']
|
||||||
cycle_id=data['cycle_id']
|
cycle_id=data['cycle_id']
|
||||||
|
@ -182,7 +197,7 @@ class GenVisit(Model):
|
||||||
dom.append(['state','=','draft'])
|
dom.append(['state','=','draft'])
|
||||||
vids=visit_obj.search(dom)
|
vids=visit_obj.search(dom)
|
||||||
visit_obj.delete(vids)
|
visit_obj.delete(vids)
|
||||||
key='%s-%s'%(vals['cycle_id'], vals['time_start'])
|
key='%s/%s'%(vals['cycle_id'], vals['time_start'])
|
||||||
if not schedules.get(key):
|
if not schedules.get(key):
|
||||||
schedules[key]={
|
schedules[key]={
|
||||||
'cycle_id': obj.cycle_id.id,
|
'cycle_id': obj.cycle_id.id,
|
||||||
|
@ -194,19 +209,40 @@ class GenVisit(Model):
|
||||||
start_date=tmp
|
start_date=tmp
|
||||||
|
|
||||||
for vals in visit_vals:
|
for vals in visit_vals:
|
||||||
vals['nurse_vals']=nurse_vals # XXX
|
|
||||||
visit_obj.create(vals)
|
visit_obj.create(vals)
|
||||||
#dom=[]
|
|
||||||
#dom.append(['time_start','>=','%s %s'%(obj.date_from[0:10],' 00:00:00')])
|
print("create schedule")
|
||||||
#dom.append(['time_stop','<=','%s %s'%(start_date.strftime(FMT_DATE)[0:10],' 23:59:59')])
|
print("="*50)
|
||||||
#dom.append(['cycle_id','=',obj.cycle_id.id])
|
for k, v in schedules.items():
|
||||||
#schedule_obj=get_model("clinic.schedule")
|
cycle_id,time_start=k.split("/")
|
||||||
#schedule_ids=schedule_obj.search(dom)
|
schedule_date=time_start[0:10]
|
||||||
#schedule_obj.delete(schedule_ids)
|
dom=[]
|
||||||
#nurse_ids=[nurse['id'] for nurse in nurse_vals]
|
dom.append(['date','=',schedule_date])
|
||||||
#for key, vals in schedules.items():
|
schedules=get_model("clinic.schedule").search_browse(dom)
|
||||||
#vals['nurses']=[('add', nurse_ids)]
|
if schedules:
|
||||||
#schedule_obj.create(vals)
|
schedule=schedules[0]
|
||||||
|
if schedule.state=='draft':
|
||||||
|
for line in schedule.lines:
|
||||||
|
line.delete()
|
||||||
|
else:
|
||||||
|
vals={
|
||||||
|
'date': time_start[0:10],
|
||||||
|
'time_start': time_start,
|
||||||
|
'time_stop': time_start,
|
||||||
|
}
|
||||||
|
schedule_id=get_model("clinic.schedule").create(vals)
|
||||||
|
schedule=get_model("clinic.schedule").browse(schedule_id)
|
||||||
|
|
||||||
|
lines=[]
|
||||||
|
for nv in nurse_vals:
|
||||||
|
nurse_id=nv['id']
|
||||||
|
lines.append(('create',{
|
||||||
|
'nurse_id': nurse_id,
|
||||||
|
'cycle_id': cycle_id,
|
||||||
|
}))
|
||||||
|
schedule.write({'lines': lines})
|
||||||
|
|
||||||
|
print("="*50)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'next': {
|
'next': {
|
||||||
|
|
|
@ -22,7 +22,6 @@ class LoadNurse(Model):
|
||||||
if cycle_ids:
|
if cycle_ids:
|
||||||
cycle_id=cycle_ids[0]
|
cycle_id=cycle_ids[0]
|
||||||
lines=[]
|
lines=[]
|
||||||
print("cycle_id ", cycle_id)
|
|
||||||
for nurse in get_model("clinic.personal").search_browse([['type','=','nurse']]):
|
for nurse in get_model("clinic.personal").search_browse([['type','=','nurse']]):
|
||||||
in_cycle_id=None
|
in_cycle_id=None
|
||||||
if nurse.cycle_id.id:
|
if nurse.cycle_id.id:
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from netforce.model import Model, fields
|
from netforce.model import Model, fields, get_model
|
||||||
from netforce.access import get_active_company
|
from netforce.access import get_active_company
|
||||||
|
|
||||||
class PersonalLevel(Model):
|
class PersonalLevel(Model):
|
||||||
|
@ -8,9 +8,9 @@ class PersonalLevel(Model):
|
||||||
_fields={
|
_fields={
|
||||||
"name": fields.Char("Name",required=True,search=True),
|
"name": fields.Char("Name",required=True,search=True),
|
||||||
'formular': fields.Text("Formular"),
|
'formular': fields.Text("Formular"),
|
||||||
'description': fields.Text("Description"),
|
'description': fields.Text("Description", search=True),
|
||||||
'sequence': fields.Integer("Sequence"),
|
'sequence': fields.Integer("Sequence"),
|
||||||
"type": fields.Selection([('personal','Personal'),("doctor","Doctor"),("nurse","Nurse")],"Personal Type",required=True),
|
"type": fields.Selection([('personal','Personal'),("doctor","Doctor"),("nurse","Nurse")],"Personal Type",required=True, search=True),
|
||||||
}
|
}
|
||||||
|
|
||||||
_defaults={
|
_defaults={
|
||||||
|
@ -22,4 +22,21 @@ class PersonalLevel(Model):
|
||||||
|
|
||||||
_order="sequence"
|
_order="sequence"
|
||||||
|
|
||||||
|
def copy(self,ids,context={}):
|
||||||
|
obj=self.browse(ids)[0]
|
||||||
|
vals={
|
||||||
|
'name': '%s (copy)'%obj.name,
|
||||||
|
'description': obj.description,
|
||||||
|
'type': obj.type,
|
||||||
|
}
|
||||||
|
new_id=get_model("clinic.personal.level").create(vals)
|
||||||
|
return {
|
||||||
|
'next': {
|
||||||
|
'name': 'clinic_personal_level',
|
||||||
|
'mode': 'form',
|
||||||
|
'active_id': new_id,
|
||||||
|
},
|
||||||
|
'flash': 'Copy has been succcesfully',
|
||||||
|
}
|
||||||
|
|
||||||
PersonalLevel.register()
|
PersonalLevel.register()
|
||||||
|
|
|
@ -12,10 +12,12 @@ class Schedule(Model):
|
||||||
res={}
|
res={}
|
||||||
for obj in self.browse(ids):
|
for obj in self.browse(ids):
|
||||||
st="\n" # XXX
|
st="\n" # XXX
|
||||||
|
count=0
|
||||||
for line in obj.lines:
|
for line in obj.lines:
|
||||||
nurse=line.nurse_id
|
nurse=line.nurse_id
|
||||||
st+='%s %s\n'%(nurse.name, nurse.level_id.name or "")
|
st+='%s %s\n'%(nurse.name, nurse.level_id.name or "")
|
||||||
res[obj.id]='%s'%(st)
|
count+=1
|
||||||
|
res[obj.id]='%s'%(st if count else 'No nurse')
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _get_item(self,ids,context={}):
|
def _get_item(self,ids,context={}):
|
||||||
|
|
|
@ -129,6 +129,15 @@ class ScheduleCopy(Model):
|
||||||
'date': date,
|
'date': date,
|
||||||
'lines': lines,
|
'lines': lines,
|
||||||
})
|
})
|
||||||
|
else:
|
||||||
|
# copy to exist nurse
|
||||||
|
schedules=get_model("clinic.schedule").search_browse([['date','=',date]])
|
||||||
|
print("update lines ", lines)
|
||||||
|
if schedules and lines:
|
||||||
|
schd=schedules[0]
|
||||||
|
for line in schd.lines:
|
||||||
|
line.delete()
|
||||||
|
schd.write({'lines': lines})
|
||||||
|
|
||||||
start_date=tmp
|
start_date=tmp
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,16 @@ class ScheduleLine(Model):
|
||||||
_name="clinic.schedule.line"
|
_name="clinic.schedule.line"
|
||||||
_string="Schedule Line"
|
_string="Schedule Line"
|
||||||
|
|
||||||
|
def _get_level(self,ids,context={}):
|
||||||
|
res={}
|
||||||
|
for obj in self.browse(ids):
|
||||||
|
res[obj.id]=obj.nurse_id.level_id.id
|
||||||
|
return res
|
||||||
_fields={
|
_fields={
|
||||||
'schedule_id': fields.Many2One("clinic.schedule","Schedule"),
|
'schedule_id': fields.Many2One("clinic.schedule","Schedule"),
|
||||||
'cycle_id': fields.Many2One("clinic.cycle","Cycle"),
|
'cycle_id': fields.Many2One("clinic.cycle","Cycle"),
|
||||||
"nurse_id": fields.Many2One("clinic.personal","Nurse",domain=[['type','=','nurse']]),
|
"nurse_id": fields.Many2One("clinic.personal","Nurse",domain=[['type','=','nurse']]),
|
||||||
|
'level_id': fields.Many2One("clinic.personal.level","Level",function="_get_level"),
|
||||||
}
|
}
|
||||||
|
|
||||||
ScheduleLine.register()
|
ScheduleLine.register()
|
||||||
|
|
|
@ -14,6 +14,7 @@ class ClinicSetting(Model):
|
||||||
_fields={
|
_fields={
|
||||||
"var_k": fields.Float("K"),
|
"var_k": fields.Float("K"),
|
||||||
'file': fields.File("File"),
|
'file': fields.File("File"),
|
||||||
|
'levels': fields.One2Many("clinic.setting.level","setting_id","Levels"),
|
||||||
}
|
}
|
||||||
|
|
||||||
def read_excel(self,fpath=None):
|
def read_excel(self,fpath=None):
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
from netforce.model import Model, fields, get_model
|
||||||
|
|
||||||
|
class SettingLevel(Model):
|
||||||
|
_name="clinic.setting.level"
|
||||||
|
_string="Setting Line"
|
||||||
|
|
||||||
|
def _get_formular(self,ids,context={}):
|
||||||
|
res={}
|
||||||
|
for obj in self.browse(ids):
|
||||||
|
res[obj.id]=''.join(['%sx'%obj.var_a or '', obj.op or '', obj.var_b or ''])
|
||||||
|
return res
|
||||||
|
|
||||||
|
_fields={
|
||||||
|
"setting_id": fields.Many2One("clinic.setting","Setting"),
|
||||||
|
"level_id": fields.Many2One("clinic.personal.level","Level",domain=[['type','=','nurse']]),
|
||||||
|
'var_a': fields.Char("Ax"),
|
||||||
|
"op": fields.Selection([["+","+"],["-","-"],["*","*"],["/","/"]],"Operation"),
|
||||||
|
'var_b': fields.Char("B"),
|
||||||
|
'formular': fields.Text("Formular",function="_get_formular"),
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingLevel.register()
|
|
@ -177,6 +177,64 @@ class Visit(Model):
|
||||||
hd_case_id=hd_case_obj.create(vals)
|
hd_case_id=hd_case_obj.create(vals)
|
||||||
if context.get("called"): #XXX call outside
|
if context.get("called"): #XXX call outside
|
||||||
return hd_case_id
|
return hd_case_id
|
||||||
|
|
||||||
|
print("checking cycle item")
|
||||||
|
date=vals['time_start'][0:10]
|
||||||
|
cycle=obj.cycle_id
|
||||||
|
dom=[]
|
||||||
|
dom.append(['date','=',date])
|
||||||
|
dom.append(['cycle_id','=',cycle.id])
|
||||||
|
dom.append(['state','=','draft'])
|
||||||
|
item_obj=get_model('clinic.cycle.item')
|
||||||
|
item_ids=item_obj.search(dom)
|
||||||
|
|
||||||
|
def get_schedule(date):
|
||||||
|
dom=[]
|
||||||
|
dom.append(['date','=',date])
|
||||||
|
schedule=None
|
||||||
|
schedules=get_model("clinic.schedule").search_browse(dom)
|
||||||
|
if schedules:
|
||||||
|
schedule=schedules[0]
|
||||||
|
return schedule
|
||||||
|
|
||||||
|
item_vals={
|
||||||
|
'cycle_id': cycle.id,
|
||||||
|
'date': date,
|
||||||
|
'nurses': [],
|
||||||
|
}
|
||||||
|
|
||||||
|
item_id=None
|
||||||
|
if not item_ids:
|
||||||
|
item_id=item_obj.create(item_vals)
|
||||||
|
else:
|
||||||
|
# clear old nurse in cycle item
|
||||||
|
item_id=item_ids[0]
|
||||||
|
item=item_obj.browse(item_id)
|
||||||
|
for nurse in item.nurses:
|
||||||
|
nurse.delete()
|
||||||
|
|
||||||
|
item=item_obj.browse(item_id)
|
||||||
|
schedule=get_schedule(date)
|
||||||
|
if schedule:
|
||||||
|
for line in schedule.lines:
|
||||||
|
if line.cycle_id.id==cycle.id:
|
||||||
|
nurse=line.nurse_id
|
||||||
|
item_vals['nurses'].append(('create',{
|
||||||
|
'nurse_id': nurse.id,
|
||||||
|
'level_id': nurse.level_id.id,
|
||||||
|
}))
|
||||||
|
|
||||||
|
item.write(item_vals)
|
||||||
|
|
||||||
|
obj.write({
|
||||||
|
'cycle_item_id': item_id,
|
||||||
|
})
|
||||||
|
|
||||||
|
hd_case=hd_case_obj.browse(hd_case_id)
|
||||||
|
hd_case.write({
|
||||||
|
'cycle_item_id': item_id,
|
||||||
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'next': {
|
'next': {
|
||||||
'name': 'clinic_hd_case',
|
'name': 'clinic_hd_case',
|
||||||
|
@ -296,50 +354,12 @@ class Visit(Model):
|
||||||
}
|
}
|
||||||
|
|
||||||
def create(self, vals,**kw):
|
def create(self, vals,**kw):
|
||||||
date=vals['time_start'][0:10]
|
|
||||||
cycle_id=vals['cycle_id']
|
cycle_id=vals['cycle_id']
|
||||||
cycle=get_model("clinic.cycle").browse(cycle_id)
|
cycle=get_model("clinic.cycle").browse(cycle_id)
|
||||||
dom=[]
|
|
||||||
dom.append(['date','=',date])
|
|
||||||
dom.append(['cycle_id','=',cycle_id])
|
|
||||||
item_obj=get_model('clinic.cycle.item')
|
|
||||||
item_ids=item_obj.search(dom)
|
|
||||||
item_id=None
|
|
||||||
|
|
||||||
nurse_vals=[]
|
|
||||||
if 'nurse_vals' in vals.keys():
|
|
||||||
nurse_vals=vals['nurse_vals']
|
|
||||||
del vals['nurse_vals']
|
|
||||||
if not item_ids:
|
|
||||||
item_vals={
|
|
||||||
'cycle_id': cycle_id,
|
|
||||||
'date': date,
|
|
||||||
'nurses': [],
|
|
||||||
}
|
|
||||||
for nurse_val in nurse_vals:
|
|
||||||
item_vals['nurses'].append(('create',{
|
|
||||||
'nurse_id': nurse_val['id'],
|
|
||||||
'level_id': nurse_val['level_id'],
|
|
||||||
}))
|
|
||||||
item_id=item_obj.create(item_vals)
|
|
||||||
else:
|
|
||||||
item_id=item_ids[0]
|
|
||||||
item_nurse_obj=get_model("clinic.cycle.item.nurse")
|
|
||||||
item_nurse_ids=item_nurse_obj.search([['cycle_item_id','=',item_id]])
|
|
||||||
item_nurse_obj.delete(item_nurse_ids)
|
|
||||||
for nurse_val in nurse_vals:
|
|
||||||
item_nurse_obj.create({
|
|
||||||
'cycle_item_id': item_id,
|
|
||||||
'nurse_id': nurse_val['id'],
|
|
||||||
'level_id': nurse_val['level_id'],
|
|
||||||
})
|
|
||||||
|
|
||||||
vals['cycle_item_id']=item_id
|
|
||||||
|
|
||||||
vals['sequence']='%s-%s'%(vals['time_start'][0:10],cycle.sequence) #date-sequence
|
vals['sequence']='%s-%s'%(vals['time_start'][0:10],cycle.sequence) #date-sequence
|
||||||
vals['visit_date']=vals['time_start'][0:10]
|
vals['visit_date']=vals['time_start'][0:10]
|
||||||
obj_id=super().create(vals,**kw)
|
new_id=super().create(vals,**kw)
|
||||||
return obj_id
|
return new_id
|
||||||
|
|
||||||
def cancel(self,ids,context={}):
|
def cancel(self,ids,context={}):
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
|
|
|
@ -1,5 +1,14 @@
|
||||||
|
=======
|
||||||
customize ui
|
customize ui
|
||||||
- attribute color for field
|
calendar -
|
||||||
|
- show search
|
||||||
|
- change color from cycle
|
||||||
|
- filter state from attr
|
||||||
|
- can print sechedule all month
|
||||||
|
- set attribute color for field
|
||||||
|
|
||||||
|
========
|
||||||
|
|
||||||
cycle dialy
|
cycle dialy
|
||||||
-list of cycle items
|
-list of cycle items
|
||||||
- report all compute all cost
|
- report all compute all cost
|
||||||
|
|
Loading…
Reference in New Issue