diff --git a/netforce_clinic/actions/clinic_merge_staff.xml b/netforce_clinic/actions/clinic_merge_staff.xml
new file mode 100644
index 0000000..fd9cde1
--- /dev/null
+++ b/netforce_clinic/actions/clinic_merge_staff.xml
@@ -0,0 +1,8 @@
+
+ form_view
+ clinic.setting
+ 1
+ clinic_merge_staff
+ clinic_menu
+
+
diff --git a/netforce_clinic/layouts/clinic_menu.xml b/netforce_clinic/layouts/clinic_menu.xml
index 6f37415..d6aa7bc 100644
--- a/netforce_clinic/layouts/clinic_menu.xml
+++ b/netforce_clinic/layouts/clinic_menu.xml
@@ -52,12 +52,13 @@
-
+
+
-
diff --git a/netforce_clinic/layouts/clinic_merge_staff.xml b/netforce_clinic/layouts/clinic_merge_staff.xml
new file mode 100644
index 0000000..faf6ea8
--- /dev/null
+++ b/netforce_clinic/layouts/clinic_merge_staff.xml
@@ -0,0 +1,11 @@
+
diff --git a/netforce_clinic/models/setting.py b/netforce_clinic/models/setting.py
index b699c7c..9c92503 100644
--- a/netforce_clinic/models/setting.py
+++ b/netforce_clinic/models/setting.py
@@ -63,6 +63,8 @@ class ClinicSetting(Model):
'helper_categ_id': fields.Many2One("clinic.staff.categ","Helper Category"),
'base_salary_day': fields.Float("Base Salary Day"),
'next_date': fields.DateTime("Next Gen"),
+ 'staff_from_id': fields.Many2One("clinic.staff","Staff From"),
+ 'staff_to_id': fields.Many2One("clinic.staff","Staff To"),
}
_defaults={
@@ -264,6 +266,58 @@ class ClinicSetting(Model):
print("z"*50)
print("Done!")
+ def merge_staff_from(self,ids,context={}):
+ user_id=get_active_user()
+ if user_id !=1:
+ print("Only admin!!")
+ return
+ obj=self.browse(1)
+ if not obj.staff_from_id:
+ raise Exception("Please Enter Staff From")
+ if not obj.staff_to_id:
+ raise Exception("Please Enter Staff To")
+ if obj.staff_from_id.type != obj.staff_to_id.type:
+ raise Exception("Staff Type not the same!")
+ db=get_connection()
+ # update FROM to TO
+ if obj.staff_from_id.type=='nurse':
+ for rec in get_model("clinic.cycle.item.line").search_browse([['nurse_id','=',obj.staff_from_id.id]]):
+ rec.write({
+ 'nurse_id': obj.staff_to_id.id,
+ })
+ dom=[
+ ['type','=','nurse'],
+ ['staff_id','=',obj.staff_from_id.id],
+ ]
+ for lcost in get_model("clinic.labor.cost.line").search_browse(dom):
+ lcost.write({
+ 'staff_id': obj.staff_to_id.id,
+ })
+ elif obj.staff_from_id.type=='doctor':
+ for rec in get_model("clinic.hd.case.staff").search_browse([['staff_id','=',obj.staff_from_id.id]]):
+ rec.write({
+ 'staff_id': obj.staff_to_id.id,
+ })
+ hdcase=rec.hd_case_id
+ vs=hdcase.visit_id
+ db.execute("update clinic_visit set doctor_id=%s where id=%s",obj.staff_to_id.id,vs.id)
+ pt=hdcase.patient_id
+ db.execute("update clinic_patient set doctor_id=%s where id=%s",obj.staff_to_id.id,pt.id)
+ citem=hdcase.cycle_item_id
+ dom=[
+ ['type','=','doctor'],
+ ['staff_id','=',obj.staff_from_id.id],
+ ['labor_cost_id.cycle_item_id','=',citem.id],
+ ]
+ for lcost in get_model("clinic.labor.cost.line").search_browse(dom):
+ lcost.write({
+ 'staff_id': obj.staff_to_id.id,
+ })
+ #del_staff=obj.staff_from_id.name
+ # delete staff
+ get_model('clinic.staff').delete([obj.staff_from_id.id])
+ print("Done!")
+
def del_duplicate_staff(self,ids,context={}):
user_id=get_active_user()
if user_id !=1: