From a5afa558e033fc837aaa6015346aff1ce890b0e6 Mon Sep 17 00:00:00 2001 From: "watcha.h" Date: Thu, 15 Oct 2015 11:31:59 +0700 Subject: [PATCH] fix get_sequence --- netforce_clinic/models/hd_case.py | 6 +++--- netforce_clinic/models/sequence.py | 8 +++++--- netforce_clinic/models/visit.py | 8 ++++---- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py index 9546245..00ae99c 100644 --- a/netforce_clinic/models/hd_case.py +++ b/netforce_clinic/models/hd_case.py @@ -288,7 +288,7 @@ class HDCase(Model): def _get_number(self,context={}): while 1: - seq_id=get_model("sequence").find_sequence(type="clinic_hdcase") + seq_id=get_model("sequence").find_sequence(type="clinic_hdcase",context=context) num=get_model("sequence").get_next_number(seq_id,context=context) if not num: return None @@ -1500,7 +1500,7 @@ class HDCase(Model): #break return vals - def create(self,vals,**kw): + def create(self,vals,context): patient_id=vals['patient_id'] if 'vascular_acc' in vals.keys(): patient=get_model("clinic.patient").browse(patient_id) @@ -1509,7 +1509,7 @@ class HDCase(Model): }) vals=self.get_staff_line(vals,patient_id) vals=self.get_hct(vals,patient_id) - new_id=super().create(vals,**kw) + new_id=super().create(vals,context) self.function_store([new_id]) return new_id diff --git a/netforce_clinic/models/sequence.py b/netforce_clinic/models/sequence.py index cdb61ae..61da104 100644 --- a/netforce_clinic/models/sequence.py +++ b/netforce_clinic/models/sequence.py @@ -69,14 +69,16 @@ class Sequence(Model): user=get_model('base.user').browse(user_id) dpt=user.department_id branch=user.branch_id - if dpt: + if context.get('branch_id'): + comp_dom=comp_dom+[["branch_id","=",context['branch_id']]] + elif dpt: branch_id=dpt.branch_id.id comp_dom=comp_dom+[["branch_id","=",branch_id]] elif branch: branch_id=branch.id comp_dom=comp_dom+[["branch_id","=",branch_id]] - elif context.get('branch_id'): - comp_dom=comp_dom+[["branch_id","=",context['branch_id']]] + #elif context.get('branch_id'): + #comp_dom=comp_dom+[["branch_id","=",context['branch_id']]] print('com_dom ', comp_dom) res=self.search(comp_dom,order="id") if res: diff --git a/netforce_clinic/models/visit.py b/netforce_clinic/models/visit.py index eda35cb..44851c2 100644 --- a/netforce_clinic/models/visit.py +++ b/netforce_clinic/models/visit.py @@ -58,7 +58,7 @@ class Visit(Model): def _get_number(self,context={}): while 1: seq_type='clinic_visit' - seq_id=get_model("sequence").find_sequence(type=seq_type) + seq_id=get_model("sequence").find_sequence(type=seq_type,context=context) if not seq_id: raise Exception("Can not found sequence %s"%seq_type) num=get_model("sequence").get_next_number(seq_id,context=context) @@ -206,7 +206,7 @@ class Visit(Model): hd_case.write(vals) hd_case_id=hd_case.id else: - hd_case_id=hd_case_obj.create(vals) + hd_case_id=hd_case_obj.create(vals,context) if context.get("called"): #XXX call outside return hd_case_id @@ -476,8 +476,8 @@ class Visit(Model): 'flash': 'Visit\'s %s has been cancelled'%obj.patient_id.name } - def create(self, vals,**kw): - new_id=super().create(vals,**kw) + def create(self, vals,context): + new_id=super().create(vals,context) self.function_store([new_id]) return new_id