From d1a45db1328242cc459bbefb2b0c843a8e4af853 Mon Sep 17 00:00:00 2001 From: "watcha.h@almacom.co.th" Date: Wed, 14 Jan 2015 18:00:14 +0700 Subject: [PATCH] add branch --- netforce_clinic/layouts/clinic_branch_form.xml | 2 +- netforce_clinic/layouts/clinic_branch_list.xml | 1 + netforce_clinic/layouts/clinic_cycle_form.xml | 2 +- netforce_clinic/layouts/clinic_hd_case_form.xml | 1 + netforce_clinic/layouts/clinic_menu.xml | 2 +- netforce_clinic/layouts/clinic_patient_form.xml | 1 + netforce_clinic/layouts/clinic_patient_list.xml | 2 +- netforce_clinic/layouts/clinic_sickbed_form.xml | 1 + netforce_clinic/layouts/clinic_staff_form.xml | 3 ++- netforce_clinic/layouts/clinic_staff_list.xml | 2 +- netforce_clinic/layouts/clinic_visit_form.xml | 1 + netforce_clinic/models/cycle.py | 2 +- netforce_clinic/models/hd_case.py | 3 +++ netforce_clinic/models/patient.py | 1 + netforce_clinic/models/sickbed.py | 14 +++++++++++++- netforce_clinic/models/staff.py | 1 + netforce_clinic/models/visit.py | 11 +++++++++++ netforce_clinic/todo.txt | 11 ++++++++++- 18 files changed, 52 insertions(+), 9 deletions(-) diff --git a/netforce_clinic/layouts/clinic_branch_form.xml b/netforce_clinic/layouts/clinic_branch_form.xml index ab07514..c3b2b3f 100644 --- a/netforce_clinic/layouts/clinic_branch_form.xml +++ b/netforce_clinic/layouts/clinic_branch_form.xml @@ -1,5 +1,5 @@
- + diff --git a/netforce_clinic/layouts/clinic_branch_list.xml b/netforce_clinic/layouts/clinic_branch_list.xml index c77373f..c8ddb27 100644 --- a/netforce_clinic/layouts/clinic_branch_list.xml +++ b/netforce_clinic/layouts/clinic_branch_list.xml @@ -1,4 +1,5 @@ + diff --git a/netforce_clinic/layouts/clinic_cycle_form.xml b/netforce_clinic/layouts/clinic_cycle_form.xml index a00db58..725f602 100644 --- a/netforce_clinic/layouts/clinic_cycle_form.xml +++ b/netforce_clinic/layouts/clinic_cycle_form.xml @@ -10,7 +10,7 @@ - + diff --git a/netforce_clinic/layouts/clinic_hd_case_form.xml b/netforce_clinic/layouts/clinic_hd_case_form.xml index 87a5223..ca87581 100644 --- a/netforce_clinic/layouts/clinic_hd_case_form.xml +++ b/netforce_clinic/layouts/clinic_hd_case_form.xml @@ -15,6 +15,7 @@ + diff --git a/netforce_clinic/layouts/clinic_menu.xml b/netforce_clinic/layouts/clinic_menu.xml index dc5a29d..3408af3 100644 --- a/netforce_clinic/layouts/clinic_menu.xml +++ b/netforce_clinic/layouts/clinic_menu.xml @@ -51,7 +51,7 @@ - + diff --git a/netforce_clinic/layouts/clinic_patient_form.xml b/netforce_clinic/layouts/clinic_patient_form.xml index ab588cf..55a2c07 100644 --- a/netforce_clinic/layouts/clinic_patient_form.xml +++ b/netforce_clinic/layouts/clinic_patient_form.xml @@ -17,6 +17,7 @@ + diff --git a/netforce_clinic/layouts/clinic_patient_list.xml b/netforce_clinic/layouts/clinic_patient_list.xml index 5dd7515..6787f2a 100644 --- a/netforce_clinic/layouts/clinic_patient_list.xml +++ b/netforce_clinic/layouts/clinic_patient_list.xml @@ -6,7 +6,7 @@ - + diff --git a/netforce_clinic/layouts/clinic_sickbed_form.xml b/netforce_clinic/layouts/clinic_sickbed_form.xml index 893361f..efede2b 100644 --- a/netforce_clinic/layouts/clinic_sickbed_form.xml +++ b/netforce_clinic/layouts/clinic_sickbed_form.xml @@ -8,6 +8,7 @@ + diff --git a/netforce_clinic/layouts/clinic_staff_form.xml b/netforce_clinic/layouts/clinic_staff_form.xml index cf242d0..8befb7a 100644 --- a/netforce_clinic/layouts/clinic_staff_form.xml +++ b/netforce_clinic/layouts/clinic_staff_form.xml @@ -11,6 +11,7 @@ + @@ -21,7 +22,7 @@ - + diff --git a/netforce_clinic/layouts/clinic_staff_list.xml b/netforce_clinic/layouts/clinic_staff_list.xml index 1674a3e..a8a8f97 100644 --- a/netforce_clinic/layouts/clinic_staff_list.xml +++ b/netforce_clinic/layouts/clinic_staff_list.xml @@ -9,7 +9,7 @@ - + diff --git a/netforce_clinic/layouts/clinic_visit_form.xml b/netforce_clinic/layouts/clinic_visit_form.xml index 4ef1eb7..54be576 100644 --- a/netforce_clinic/layouts/clinic_visit_form.xml +++ b/netforce_clinic/layouts/clinic_visit_form.xml @@ -15,6 +15,7 @@ + diff --git a/netforce_clinic/models/cycle.py b/netforce_clinic/models/cycle.py index 138c286..d35cdda 100644 --- a/netforce_clinic/models/cycle.py +++ b/netforce_clinic/models/cycle.py @@ -7,7 +7,7 @@ class Cycle(Model): _name="clinic.cycle" _string="Cycle" _key=["name"] - _multi_company=True + #_multi_company=True def _get_duration(self,ids,context={}): res={} diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py index 9d5d3d3..a639ec5 100644 --- a/netforce_clinic/models/hd_case.py +++ b/netforce_clinic/models/hd_case.py @@ -125,6 +125,7 @@ class HDCase(Model): 'req_fee': fields.Integer("Request Expense"), 'hd_case_id': fields.Many2One("clinic.hd.case","HD",function="_get_all",function_multi=True), # XXX 'company_id': fields.Many2One("company","Company"), + 'branch_id': fields.Many2One("clinic.branch","Branch"), } def _get_number(self,context={}): @@ -209,6 +210,7 @@ class HDCase(Model): if patient_id: patient=get_model('clinic.patient').browse(patient_id) department=patient.department_id + branch=patient.branch_id cycle=patient.cycle_id partner=patient.type_id.contact_id if partner: @@ -216,6 +218,7 @@ class HDCase(Model): else: data['fee_partner_id']=None data['department_id']=department.id + data['branch_id']=branch.id data['cycle_id']=cycle.id data['patient_type_id']=patient.type_id.id if patient.type_id.hct_include: diff --git a/netforce_clinic/models/patient.py b/netforce_clinic/models/patient.py index ffc08c8..3ec783d 100644 --- a/netforce_clinic/models/patient.py +++ b/netforce_clinic/models/patient.py @@ -100,6 +100,7 @@ class Patient(Model): 'rm_remain_visit': fields.Boolean("Auto Remove Remaining Visit"), 'department_id': fields.Many2One("clinic.department","Department"), 'cycle_id': fields.Many2One("clinic.cycle","Last Cycle",function="_get_last_cycle"), + 'branch_id': fields.Many2One("clinic.branch","Branch"), } def _get_number(self,context={}): diff --git a/netforce_clinic/models/sickbed.py b/netforce_clinic/models/sickbed.py index bae99fc..8203ad5 100644 --- a/netforce_clinic/models/sickbed.py +++ b/netforce_clinic/models/sickbed.py @@ -1,5 +1,5 @@ from netforce.model import Model, fields, get_model -from netforce.access import get_active_company +from netforce.access import get_active_company, get_active_user class SickBed(Model): _name="clinic.sickbed" @@ -35,13 +35,25 @@ class SickBed(Model): "state": fields.Selection([("available","Available"),("not_available","Not Available")],"Status"), 'sequence': fields.Integer("Sequence"), 'note': fields.Text("Note"), + 'branch_id': fields.Many2One("clinic.branch","Branch",required=True, search=True), } + + def _get_sickbed(self,context={}): + user_id=get_active_user() + staffs=get_model("clinic.staff").search_browse([['user_id','=',user_id]]) + branch_id=None + if staffs: + staff=staffs[0] + if staff.branch_id: + branch_id=staff.branch_id.id + return branch_id _defaults={ 'available': True, "company_id": lambda *a: get_active_company(), 'sequence': 0, 'state': 'available', + 'branch_id': _get_sickbed, } _order="sequence" diff --git a/netforce_clinic/models/staff.py b/netforce_clinic/models/staff.py index 3807da0..92d6c1a 100644 --- a/netforce_clinic/models/staff.py +++ b/netforce_clinic/models/staff.py @@ -116,6 +116,7 @@ class Staff(Model): "hd_case_staffs": fields.One2Many("clinic.hd.case.staff","staff_id","HD Cases"), "hd_cases": fields.Many2Many("clinic.hd.case","HD Cases",function="_get_hdcase"), # not need to use (it's slow to load) "cycle_item_nurses": fields.One2Many("clinic.cycle.item.nurse","nurse_id","Cycle Items"), + 'branch_id': fields.Many2One("clinic.branch","Branch"), } def _get_number(self,context={}): diff --git a/netforce_clinic/models/visit.py b/netforce_clinic/models/visit.py index 054bcaf..60d2c55 100644 --- a/netforce_clinic/models/visit.py +++ b/netforce_clinic/models/visit.py @@ -51,6 +51,7 @@ class Visit(Model): 'visit_date': fields.Date('Visit Date'), 'cycle_color': fields.Char('Color',function="_get_all",function_multi=True,store=True), 'note': fields.Text('Note'), + 'branch_id': fields.Many2One("clinic.branch","Branch"), } def _get_number(self,context={}): @@ -163,6 +164,7 @@ class Visit(Model): 'time_stop': obj.time_stop, 'cycle_id' : obj.cycle_id.id, 'visit_id': obj.id, + 'branch_id': obj.branch_id.id, 'lines':[], 'dialyzers': [], 'staffs': [], @@ -279,8 +281,15 @@ class Visit(Model): elif patient.department_id: department_id=patient.department_id.id + branch_id=None + if visit.branch_id: + branch_id=visit.branch_id.id + elif patient.branch_id: + branch_id=patient.branch_id.id + print("branch_id ", branch_id) data['doctor_id']=doctor.id data['department_id']=department_id + data['branch_id']=branch_id if not patient.doctor_id: patient.write({ @@ -289,8 +298,10 @@ class Visit(Model): else: doctor=patient.doctor_id department=patient.department_id + branch=patient.branch_id data['doctor_id']=doctor.id data['department_id']=department.id + data['branch_id']=branch.id return data diff --git a/netforce_clinic/todo.txt b/netforce_clinic/todo.txt index 848b08f..b37979c 100644 --- a/netforce_clinic/todo.txt +++ b/netforce_clinic/todo.txt @@ -1 +1,10 @@ -onclick hd case on staff +sharing setting + - filter by branch + - patient + - staff + - visit + - hd case + - cycle item + - sickbed + - add popup to new dialyser + - running number