patient
parent
251ca4a592
commit
fd63be1777
|
@ -1,4 +1,5 @@
|
|||
<form model="clinic.nation">
|
||||
<field name="name"/>
|
||||
<field name="code"/>
|
||||
<field name="default"/>
|
||||
</form>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<list model="clinic.nation">
|
||||
<field name="name"/>
|
||||
<field name="code"/>
|
||||
<field name="default"/>
|
||||
</list>
|
||||
|
|
|
@ -8,6 +8,17 @@ class Nation(Model):
|
|||
_fields={
|
||||
"name": fields.Char("Name",required=True,search=True),
|
||||
"code": fields.Char("Code",search=True),
|
||||
'default': fields.Boolean("Default"),
|
||||
}
|
||||
|
||||
def write(self,ids,vals,**kw):
|
||||
default=vals.get('default')
|
||||
if default:
|
||||
for obj in self.search_browse([]):
|
||||
if obj.id not in ids:
|
||||
obj.write({
|
||||
'default': False,
|
||||
})
|
||||
super().write(ids,vals,**kw)
|
||||
|
||||
Nation.register()
|
||||
|
|
|
@ -227,6 +227,12 @@ class Patient(Model):
|
|||
code=','.join([dpt.code for dpt in dpts])
|
||||
return code
|
||||
|
||||
def _get_nation(self,context={}):
|
||||
nid=None
|
||||
for nt in get_model("clinic.nation").search_browse([['default','=',True]]):
|
||||
nid=nt.id
|
||||
return nid
|
||||
|
||||
_defaults={
|
||||
#"number": _get_number,
|
||||
"number": "",
|
||||
|
@ -241,6 +247,7 @@ class Patient(Model):
|
|||
'walkin': 'no',
|
||||
'departments': _get_departments,
|
||||
'location': _get_default_location,
|
||||
'nation_id': _get_nation,
|
||||
}
|
||||
|
||||
_sql_constraints=("clinic_patient_key_uniq","unique(name_check,branch_id)","name should be unique"),
|
||||
|
@ -248,12 +255,15 @@ class Patient(Model):
|
|||
|
||||
def check_idcard(self,card_type,idcard=''):
|
||||
res=True
|
||||
print(card_type , idcard)
|
||||
if not idcard:
|
||||
return False
|
||||
if card_type!='identification':
|
||||
return False
|
||||
if idcard=='/':
|
||||
return True
|
||||
if idcard.isalpha():
|
||||
if not idcard:
|
||||
res=False
|
||||
elif idcard.isalpha():
|
||||
res=False
|
||||
elif len(idcard)!=13:
|
||||
res=False
|
||||
|
|
Loading…
Reference in New Issue