diff --git a/netforce_clinic/layouts/clinic_branch_form.xml b/netforce_clinic/layouts/clinic_branch_form.xml index c3b2b3f..04fa546 100644 --- a/netforce_clinic/layouts/clinic_branch_form.xml +++ b/netforce_clinic/layouts/clinic_branch_form.xml @@ -1,5 +1,6 @@
+ diff --git a/netforce_clinic/layouts/clinic_branch_list.xml b/netforce_clinic/layouts/clinic_branch_list.xml index c8ddb27..8310e55 100644 --- a/netforce_clinic/layouts/clinic_branch_list.xml +++ b/netforce_clinic/layouts/clinic_branch_list.xml @@ -1,5 +1,6 @@ + diff --git a/netforce_clinic/layouts/clinic_cycle_item_form.xml b/netforce_clinic/layouts/clinic_cycle_item_form.xml index cd6f04f..2debbd9 100644 --- a/netforce_clinic/layouts/clinic_cycle_item_form.xml +++ b/netforce_clinic/layouts/clinic_cycle_item_form.xml @@ -7,10 +7,12 @@ - - - - + + + + + + diff --git a/netforce_clinic/layouts/clinic_cycle_item_list.xml b/netforce_clinic/layouts/clinic_cycle_item_list.xml index c320e5b..b0f1dda 100644 --- a/netforce_clinic/layouts/clinic_cycle_item_list.xml +++ b/netforce_clinic/layouts/clinic_cycle_item_list.xml @@ -1,5 +1,6 @@ + diff --git a/netforce_clinic/layouts/clinic_department_form.xml b/netforce_clinic/layouts/clinic_department_form.xml index cc9c2e9..5b2b9d7 100644 --- a/netforce_clinic/layouts/clinic_department_form.xml +++ b/netforce_clinic/layouts/clinic_department_form.xml @@ -1,7 +1,8 @@
- + + diff --git a/netforce_clinic/layouts/clinic_menu.xml b/netforce_clinic/layouts/clinic_menu.xml index 3408af3..4c1f796 100644 --- a/netforce_clinic/layouts/clinic_menu.xml +++ b/netforce_clinic/layouts/clinic_menu.xml @@ -1,9 +1,9 @@ - - - + + +
@@ -51,7 +51,7 @@ - + diff --git a/netforce_clinic/layouts/clinic_schedule_form.xml b/netforce_clinic/layouts/clinic_schedule_form.xml index 001708a..eadf7db 100644 --- a/netforce_clinic/layouts/clinic_schedule_form.xml +++ b/netforce_clinic/layouts/clinic_schedule_form.xml @@ -22,6 +22,7 @@ + diff --git a/netforce_clinic/layouts/clinic_sickbed_form.xml b/netforce_clinic/layouts/clinic_sickbed_form.xml index efede2b..2633130 100644 --- a/netforce_clinic/layouts/clinic_sickbed_form.xml +++ b/netforce_clinic/layouts/clinic_sickbed_form.xml @@ -8,7 +8,7 @@ - + diff --git a/netforce_clinic/layouts/clinic_sickbed_list.xml b/netforce_clinic/layouts/clinic_sickbed_list.xml index 4fb1605..58f968d 100644 --- a/netforce_clinic/layouts/clinic_sickbed_list.xml +++ b/netforce_clinic/layouts/clinic_sickbed_list.xml @@ -3,7 +3,7 @@ - + diff --git a/netforce_clinic/layouts/clinic_staff_form.xml b/netforce_clinic/layouts/clinic_staff_form.xml index 8befb7a..e06150f 100644 --- a/netforce_clinic/layouts/clinic_staff_form.xml +++ b/netforce_clinic/layouts/clinic_staff_form.xml @@ -8,6 +8,7 @@ + @@ -22,7 +23,6 @@ - diff --git a/netforce_clinic/layouts/clinic_visit_form.xml b/netforce_clinic/layouts/clinic_visit_form.xml index 54be576..de11f77 100644 --- a/netforce_clinic/layouts/clinic_visit_form.xml +++ b/netforce_clinic/layouts/clinic_visit_form.xml @@ -15,7 +15,7 @@ - + diff --git a/netforce_clinic/models/branch.py b/netforce_clinic/models/branch.py index 3516d2e..bad47e8 100644 --- a/netforce_clinic/models/branch.py +++ b/netforce_clinic/models/branch.py @@ -7,6 +7,7 @@ class Branch(Model): _key=['name'] _fields={ "name": fields.Char("Name",required=True,search=True), + "code": fields.Char("Code",required=True,search=True), "parent_id": fields.Many2One("clinic.branch","Parent"), "company_id": fields.Many2One("company","Company"), } diff --git a/netforce_clinic/models/cycle_item.py b/netforce_clinic/models/cycle_item.py index 2e5680f..cee01ae 100644 --- a/netforce_clinic/models/cycle_item.py +++ b/netforce_clinic/models/cycle_item.py @@ -38,23 +38,30 @@ class CycleItem(Model): 'user_id': fields.Many2One("base.user","Validator"), "comments": fields.One2Many("message","related_id","Comments"), "company_id": fields.Many2One("company","Company"), 'company_id': fields.Many2One("company", "Company"), + 'branch_id': fields.Many2One("clinic.branch", "Branch"), } def _get_vark(self,context={}): st=get_model("clinic.setting").browse(1) return st.var_k or 0 + def _get_branch(self,context={}): + b_ids=get_model('clinic.branch').search([]) + if b_ids: + return b_ids[0] + _defaults={ 'state': 'draft', 'company_id': lambda *a: get_active_company(), 'date': lambda *a: time.strftime("%Y-%m-%d"), 'user_id': lambda *a: get_active_user(), 'var_k': _get_vark, + 'branch_id': _get_branch, } _order="date desc" _sql_constraints=[ - ("cycle_item_uniq","unique (cycle_id,date,company_id)","Cycle item should be unique"), + ("cycle_item_uniq","unique (cycle_id,date,company_id,branch_id)","Cycle item should be unique"), ] def get_cycle_daily(self,date): diff --git a/netforce_clinic/models/department.py b/netforce_clinic/models/department.py index 88535d6..8b77e1b 100644 --- a/netforce_clinic/models/department.py +++ b/netforce_clinic/models/department.py @@ -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 class Department(Model): @@ -11,11 +11,18 @@ class Department(Model): "code": fields.Char("Code",search=True), "parent_id": fields.Many2One("clinic.department", "Parent"), 'company_id': fields.Many2One("company","Company"), + 'branch_id': fields.Many2One("clinic.branch","Branch"), "pick_out_journal_id": fields.Many2One("stock.journal","Stock Journal",required=True), } + + def _get_branch(self,context={}): + b_ids=get_model('clinic.branch').search([]) + if b_ids: + return b_ids[0] _defaults={ 'company_id': lambda *a: get_active_company(), + 'branch_id': _get_branch, } Department.register() diff --git a/netforce_clinic/models/patient.py b/netforce_clinic/models/patient.py index 3ec783d..79edc8c 100644 --- a/netforce_clinic/models/patient.py +++ b/netforce_clinic/models/patient.py @@ -100,7 +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"), + 'branch_id': fields.Many2One("clinic.branch","Branch",search=True), } def _get_number(self,context={}): @@ -133,11 +133,17 @@ class Patient(Model): ptype_id=ptype.id break return ptype_id + + def _get_branch(self,context={}): + b_ids=get_model('clinic.branch').search([]) + if b_ids: + return b_ids[0] _defaults={ "number": _get_number, "reg_date": lambda *a: time.strftime("%Y-%m-%d"), "company_id": lambda *a: get_active_company(), + 'branch_id': _get_branch, 'card_type': 'identification', 'type_id': _get_type, "active" : True, diff --git a/netforce_clinic/models/schedule.py b/netforce_clinic/models/schedule.py index 0facadb..722990c 100644 --- a/netforce_clinic/models/schedule.py +++ b/netforce_clinic/models/schedule.py @@ -44,6 +44,7 @@ class Schedule(Model): 'date': fields.Date("Date",required=True,search=True), 'lines': fields.One2Many("clinic.schedule.line","schedule_id","Lines"), 'company_id': fields.Many2One("company","Company"), + 'branch_id': fields.Many2One("clinic.branch","Branch",required=True, search=True), 'state': fields.Selection([['draft','Draft'],['confirmed', 'Confirmed']],'State',search=True), 'user_id': fields.Many2One("base.user","Confirm By"), } @@ -52,9 +53,15 @@ class Schedule(Model): datenow=datetime.now().strftime("%Y-%m-%d") return datenow + def _get_branch(self,context={}): + b_ids=get_model("clinic.branch").search([]) + if b_ids: + return b_ids[0] + _defaults={ 'user_id': lambda *a: get_active_user(), "company_id": lambda *a: get_active_company(), + 'branch_id': _get_branch, 'date': _get_date, 'time_start': lambda *a: datetime.now().strftime("%Y-%m-%d %H:%M:%S"), 'time_stop': lambda *a: (datetime.now()+timedelta(seconds=3600)).strftime("%Y-%m-%d %H:%M:%S"), @@ -64,7 +71,7 @@ class Schedule(Model): _order="date desc" _sql_constraints=[ - ('schedule_uniq','unique (date,company_id)','Date should be unique'), + ('schedule_uniq','unique (date,company_id,branch_id)','Date should be unique'), ] def confirm(self,ids,context={}): diff --git a/netforce_clinic/models/sickbed.py b/netforce_clinic/models/sickbed.py index 8203ad5..6dedf44 100644 --- a/netforce_clinic/models/sickbed.py +++ b/netforce_clinic/models/sickbed.py @@ -4,6 +4,7 @@ from netforce.access import get_active_company, get_active_user class SickBed(Model): _name="clinic.sickbed" _string="Sickbed" + _key=['name','branch_id'] def _get_all(self,ids,context={}): res={} @@ -38,7 +39,7 @@ class SickBed(Model): 'branch_id': fields.Many2One("clinic.branch","Branch",required=True, search=True), } - def _get_sickbed(self,context={}): + def _get_branch(self,context={}): user_id=get_active_user() staffs=get_model("clinic.staff").search_browse([['user_id','=',user_id]]) branch_id=None @@ -53,7 +54,7 @@ class SickBed(Model): "company_id": lambda *a: get_active_company(), 'sequence': 0, 'state': 'available', - 'branch_id': _get_sickbed, + 'branch_id': _get_branch, } _order="sequence" diff --git a/netforce_clinic/models/staff.py b/netforce_clinic/models/staff.py index 92d6c1a..a116fc9 100644 --- a/netforce_clinic/models/staff.py +++ b/netforce_clinic/models/staff.py @@ -116,7 +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"), + 'branch_id': fields.Many2One("clinic.branch","Branch", search=True), } def _get_number(self,context={}): diff --git a/netforce_clinic/models/visit.py b/netforce_clinic/models/visit.py index 60d2c55..222e9ed 100644 --- a/netforce_clinic/models/visit.py +++ b/netforce_clinic/models/visit.py @@ -196,9 +196,11 @@ class Visit(Model): date=vals['time_start'][0:10] cycle=obj.cycle_id + branch=obj.branch_id dom=[] dom.append(['date','=',date]) dom.append(['cycle_id','=',cycle.id]) + dom.append(['branch_id','=',branch.id]) item_obj=get_model('clinic.cycle.item') item_ids=item_obj.search(dom) @@ -213,6 +215,7 @@ class Visit(Model): item_vals={ 'cycle_id': cycle.id, + 'branch_id': branch.id, 'date': date, 'nurses': [], } diff --git a/netforce_clinic/todo.txt b/netforce_clinic/todo.txt index b37979c..102de9d 100644 --- a/netforce_clinic/todo.txt +++ b/netforce_clinic/todo.txt @@ -1,10 +1,23 @@ sharing setting - filter by branch - - patient - - staff - - visit - - hd case - - cycle item - - sickbed + - patient -> ok + - staff -> ok + - nurse ยังไม่มีรายชื่อสาขาที่เขาเลือก + - doctor ยังไม่ match ก้ับคนไข้ + - visit -> ok + - hd case -> ok + - cycle item -> ok + - department -> ok + - sickbed -> ok + - schedule -> + - dialyser + - add popup to new dialyser - running number + +user: + - update hd case + +link: + clinic.rddialysis.co.th + test.rddialysis.co.th