diff --git a/netforce_clinic/actions/clinic_visit_dialy.xml b/netforce_clinic/actions/clinic_visit_dialy.xml
index ed812d0..b49b346 100644
--- a/netforce_clinic/actions/clinic_visit_dialy.xml
+++ b/netforce_clinic/actions/clinic_visit_dialy.xml
@@ -5,6 +5,6 @@
visit_date
visit_date,cycle_id
- clinic_visit_dialy
+
clinic_menu
diff --git a/netforce_clinic/layouts/clinic_cycle_item_form.xml b/netforce_clinic/layouts/clinic_cycle_item_form.xml
index a0ab314..d8aa5d3 100644
--- a/netforce_clinic/layouts/clinic_cycle_item_form.xml
+++ b/netforce_clinic/layouts/clinic_cycle_item_form.xml
@@ -12,12 +12,14 @@
-
+
+
+
diff --git a/netforce_clinic/layouts/clinic_visit_dialy.xml b/netforce_clinic/layouts/clinic_visit_dialy.xml
deleted file mode 100644
index a0fc11c..0000000
--- a/netforce_clinic/layouts/clinic_visit_dialy.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/netforce_clinic/layouts/clinic_visit_form.xml b/netforce_clinic/layouts/clinic_visit_form.xml
index 93878ec..44c2815 100644
--- a/netforce_clinic/layouts/clinic_visit_form.xml
+++ b/netforce_clinic/layouts/clinic_visit_form.xml
@@ -28,7 +28,7 @@
-
+
diff --git a/netforce_clinic/layouts/clinic_visit_list.xml b/netforce_clinic/layouts/clinic_visit_list.xml
index 35bdc29..468d732 100644
--- a/netforce_clinic/layouts/clinic_visit_list.xml
+++ b/netforce_clinic/layouts/clinic_visit_list.xml
@@ -1,17 +1,10 @@
-
-
-
-
-
-
-
-
-
+
-
-
+
+
+
diff --git a/netforce_clinic/models/cycle_item.py b/netforce_clinic/models/cycle_item.py
index f06663b..07a9729 100644
--- a/netforce_clinic/models/cycle_item.py
+++ b/netforce_clinic/models/cycle_item.py
@@ -51,5 +51,17 @@ class CycleItem(Model):
cycle=obj.cycle_id
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()
diff --git a/netforce_clinic/models/cycle_item_nurse.py b/netforce_clinic/models/cycle_item_nurse.py
index ce513e8..56bdd7c 100644
--- a/netforce_clinic/models/cycle_item_nurse.py
+++ b/netforce_clinic/models/cycle_item_nurse.py
@@ -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']]),
}
diff --git a/netforce_clinic/models/gen_visit.py b/netforce_clinic/models/gen_visit.py
index c7b808f..08126a8 100644
--- a/netforce_clinic/models/gen_visit.py
+++ b/netforce_clinic/models/gen_visit.py
@@ -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)
diff --git a/netforce_clinic/models/visit.py b/netforce_clinic/models/visit.py
index 691705a..e6f4684 100644
--- a/netforce_clinic/models/visit.py
+++ b/netforce_clinic/models/visit.py
@@ -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]
diff --git a/netforce_clinic/todo.txt b/netforce_clinic/todo.txt
index 08f3949..b8e66be 100644
--- a/netforce_clinic/todo.txt
+++ b/netforce_clinic/todo.txt
@@ -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