diff --git a/netforce_clinic/layouts/clinic_patient_form.xml b/netforce_clinic/layouts/clinic_patient_form.xml index d1e9810..b7b32ae 100644 --- a/netforce_clinic/layouts/clinic_patient_form.xml +++ b/netforce_clinic/layouts/clinic_patient_form.xml @@ -35,7 +35,7 @@ - + diff --git a/netforce_clinic/models/nation.py b/netforce_clinic/models/nation.py index 8a97756..78b0770 100644 --- a/netforce_clinic/models/nation.py +++ b/netforce_clinic/models/nation.py @@ -6,8 +6,8 @@ class Nation(Model): _key=['code'] _fields={ - "code": fields.Char("Name",required=True,search=True), - "name": fields.Char("Code",search=True), + "name": fields.Char("Name",required=True,search=True), + "code": fields.Char("Code",search=True), } Nation.register() diff --git a/netforce_clinic/models/patient.py b/netforce_clinic/models/patient.py index e2c739f..513b392 100644 --- a/netforce_clinic/models/patient.py +++ b/netforce_clinic/models/patient.py @@ -248,6 +248,7 @@ class Patient(Model): def check_idcard(self,card_type,idcard=''): res=True + print(card_type , idcard) if card_type!='identification': return False if idcard=='/': @@ -326,8 +327,6 @@ class Patient(Model): else: vals['state']='admit' vals['rm_remain_visit']=False - if 'card_no' in vals.keys(): - self.check_idcard(vals.get("card_type",""),vals['card_no']) ctx={} if 'active' in vals.keys(): if not vals['active']: @@ -414,7 +413,8 @@ class Patient(Model): self.function_store(ids,context=ctx) # update name of partner for obj in self.browse(ids): - print(obj.name or "") + if obj.card_type=='identification': + self.check_idcard(obj.card_type, obj.card_no) obj.partner_id.write({ 'type': 'person', 'first_name': obj.first_name or "", @@ -494,4 +494,19 @@ class Patient(Model): def onchange_state(self,ids,context={}): pass + def onchange_nation(self,context={}): + data=context['data'] + nation_id=data['nation_id'] + if nation_id: + nation=get_model("clinic.nation").browse(nation_id) + if nation.code: + if nation.code=='TH': + data['card_type']='identification' + else: + data['card_type']='' + else: + data['card_type']='' + + return data + Patient.register()