reset cycle item nurse
parent
a90e0daee9
commit
24d1bf3338
|
@ -5,6 +5,6 @@
|
|||
<!--<field name="domain">[["order_id.state","in",["confirmed","done"]]]</field>-->
|
||||
<field name="group_fields">visit_date</field>
|
||||
<field name="group_select">visit_date,cycle_id</field>
|
||||
<field name="view_xml">clinic_visit_dialy</field>
|
||||
<!--<field name="view_xml">clinic_visit_dialy</field>-->
|
||||
<field name="menu">clinic_menu</field>
|
||||
</action>
|
||||
|
|
|
@ -12,12 +12,14 @@
|
|||
<field name="nurses" nolabel="1">
|
||||
<list>
|
||||
<field name="nurse_id"/>
|
||||
<field name="categ_id"/>
|
||||
<field name="level_id"/>
|
||||
</list>
|
||||
</field>
|
||||
</tab>
|
||||
</tabs>
|
||||
<foot>
|
||||
<button string="Validate" type="success" method="validate" icon="ok" states="draft" />
|
||||
<button string="To Draft" type="default" method="to_draft" icon="repeat" states="done" />
|
||||
</foot>
|
||||
<related>
|
||||
<field name="visits"/>
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
<list model="clinic.visit" colors='{"#cfc":[["state","=","confirmed"]],"#bcbbb9":[["state","=","cancelled"]]}'>
|
||||
<field name="number"/>
|
||||
<field name="visit_date"/>
|
||||
<field name="cycle_id"/>
|
||||
<field name="patient_id"/>
|
||||
<field name="doctor_id"/>
|
||||
<field name="department_id"/>
|
||||
<field name="state"/>
|
||||
</list>
|
|
@ -28,7 +28,7 @@
|
|||
</tabs>
|
||||
<foot>
|
||||
<button string="Confirm" type="success" method="confirm" states="draft" />
|
||||
<button string="Cancel" type="danger" method="cancel" states="draft" />
|
||||
<button string="Discard" type="danger" method="cancel" states="draft" />
|
||||
<button string="To Draft" type="default" icon="repeat" method="to_draft" states="confirmed,cancelled" />
|
||||
</foot>
|
||||
<related>
|
||||
|
|
|
@ -1,17 +1,10 @@
|
|||
<list model="clinic.visit" colors='{"#cfc":[["state","=","confirmed"]],"#bcbbb9":[["state","=","cancelled"]]}'>
|
||||
<search>
|
||||
<list model="clinic.visit" colors='{"#cfc":[["state","=","confirmed"]],"#dbdbdb":[["state","=","cancelled"]]}'>
|
||||
<field name="number"/>
|
||||
<field name="time_start"/>
|
||||
<field name="time_stop"/>
|
||||
<field name="cycle_id"/>
|
||||
<field name="patient_id"/>
|
||||
<field name="doctor_id"/>
|
||||
</search>
|
||||
<field name="number"/>
|
||||
<field name="time_start"/>
|
||||
<field name="time_stop"/>
|
||||
<field name="visit_date"/>
|
||||
<field name="cycle_id"/>
|
||||
<field name="patient_id"/>
|
||||
<field name="doctor_id"/>
|
||||
<field name="department_id"/>
|
||||
<field name="nurse_id"/>
|
||||
<field name="state"/>
|
||||
</list>
|
||||
|
|
|
@ -52,4 +52,16 @@ class CycleItem(Model):
|
|||
vals['sequence']='%s-%s'%(obj.date,cycle.sequence) #date-sequence
|
||||
super().write(ids,vals,**kw)
|
||||
|
||||
def validate(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
obj.write({
|
||||
'state': 'done',
|
||||
})
|
||||
|
||||
def to_draft(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
obj.write({
|
||||
'state': 'draft',
|
||||
})
|
||||
|
||||
CycleItem.register()
|
||||
|
|
|
@ -7,7 +7,7 @@ class CycleItemNurse(Model):
|
|||
|
||||
_fields={
|
||||
'cycle_item_id': fields.Many2One("clinic.cycle.item", "Cycle Item"),
|
||||
'categ_id': fields.Many2One("clinic.personal.categ", "Category",),
|
||||
'level_id': fields.Many2One("clinic.personal.level", "Level",),
|
||||
'nurse_id': fields.Many2One("clinic.personal",'Nurse',domain=[['type','=','nurse']]),
|
||||
}
|
||||
|
||||
|
|
|
@ -128,14 +128,21 @@ class GenVisit(Model):
|
|||
else:
|
||||
raise Exception("Please select some patient or patient type")
|
||||
|
||||
nurse_ids=[]
|
||||
nurse_vals=[]
|
||||
for nurse_line in obj.nurse_lines:
|
||||
nurse_id=nurse_line.nurse_id.id
|
||||
nurse=nurse_line.nurse_id
|
||||
# None
|
||||
if nurse_id:
|
||||
nurse_ids.append(nurse_id)
|
||||
if not nurse_ids:
|
||||
nurse_ids=get_model("clinic.personal").search([['type','=','nurse'],['categ_id','=',obj.nurse_categ_id.id]])
|
||||
if nurse:
|
||||
nurse_vals.append({
|
||||
'id': nurse.id,
|
||||
'level_id': nurse.level_id.id,
|
||||
})
|
||||
if not nurse_vals:
|
||||
for nurse in get_model("clinic.personal").search_browse([['type','=','nurse'],['categ_id','=',obj.nurse_categ_id.id]]):
|
||||
nurse_vals.append({
|
||||
'id': nurse.id,
|
||||
'level_id': nurse.level_id.id,
|
||||
})
|
||||
schedules={}
|
||||
for patient_id in patients:
|
||||
patient=get_model("clinic.patient").browse(patient_id)
|
||||
|
@ -188,7 +195,7 @@ class GenVisit(Model):
|
|||
start_date=tmp
|
||||
|
||||
for vals in visit_vals:
|
||||
vals['nurse_ids']=nurse_ids
|
||||
vals['nurse_vals']=nurse_vals # XXX
|
||||
visit_obj.create(vals)
|
||||
dom=[]
|
||||
dom.append(['time_start','>=','%s %s'%(obj.date_from[0:10],' 00:00:00')])
|
||||
|
@ -197,6 +204,7 @@ class GenVisit(Model):
|
|||
schedule_obj=get_model("clinic.schedule")
|
||||
schedule_ids=schedule_obj.search(dom)
|
||||
schedule_obj.delete(schedule_ids)
|
||||
nurse_ids=[nurse['id'] for nurse in nurse_vals]
|
||||
for key, vals in schedules.items():
|
||||
vals['nurses']=[('add', nurse_ids)]
|
||||
schedule_obj.create(vals)
|
||||
|
|
|
@ -35,7 +35,7 @@ class Visit(Model):
|
|||
"comments": fields.One2Many("message","related_id","Comments"),
|
||||
'visit_date': fields.Date('Visit Date'),
|
||||
'print_date': fields.Date('Print Date',function="_get_print_date"),
|
||||
'cycle_item_id': fields.Many2One("clinic.cycle.item","Cycle Item", on_delete="cascade"), #XXX on_delete="cascade" -> rm visit from cycle item
|
||||
'cycle_item_id': fields.Many2One("clinic.cycle.item","Cycle Item"), #XXX on_delete="cascade" -> rm visit from cycle item
|
||||
'sequence': fields.Char("Sequence"),
|
||||
}
|
||||
|
||||
|
@ -297,18 +297,34 @@ class Visit(Model):
|
|||
item_ids=item_obj.search(dom)
|
||||
item_id=None
|
||||
# XXX
|
||||
nurse_ids=[]
|
||||
if 'nurse_ids' in vals.keys():
|
||||
nurse_ids=vals['nurse_ids']
|
||||
del vals['nurse_ids']
|
||||
nurse_vals=[]
|
||||
if 'nurse_vals' in vals.keys():
|
||||
nurse_vals=vals['nurse_vals']
|
||||
del vals['nurse_vals']
|
||||
if not item_ids:
|
||||
item_id=item_obj.create({
|
||||
item_vals={
|
||||
'cycle_id': cycle_id,
|
||||
'date': date,
|
||||
'nurses': [('create',{'nurse_id': nurse_id}) for nurse_id in nurse_ids]
|
||||
})
|
||||
'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['visit_date']=vals['time_start'][0:10]
|
||||
|
|
|
@ -11,6 +11,7 @@ flow:
|
|||
======
|
||||
missing:
|
||||
- search calendar
|
||||
- can not move schedule in calendar
|
||||
- color calendar
|
||||
- can not move calendar's schedule
|
||||
- order's visit report dialy
|
||||
|
|
Loading…
Reference in New Issue