conv_bal
watcha.h 2015-03-17 11:59:23 +07:00
parent 251ca4a592
commit fd63be1777
4 changed files with 25 additions and 2 deletions

View File

@ -1,4 +1,5 @@
<form model="clinic.nation"> <form model="clinic.nation">
<field name="name"/> <field name="name"/>
<field name="code"/> <field name="code"/>
<field name="default"/>
</form> </form>

View File

@ -1,4 +1,5 @@
<list model="clinic.nation"> <list model="clinic.nation">
<field name="name"/> <field name="name"/>
<field name="code"/> <field name="code"/>
<field name="default"/>
</list> </list>

View File

@ -8,6 +8,17 @@ class Nation(Model):
_fields={ _fields={
"name": fields.Char("Name",required=True,search=True), "name": fields.Char("Name",required=True,search=True),
"code": fields.Char("Code",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() Nation.register()

View File

@ -227,6 +227,12 @@ class Patient(Model):
code=','.join([dpt.code for dpt in dpts]) code=','.join([dpt.code for dpt in dpts])
return code 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={ _defaults={
#"number": _get_number, #"number": _get_number,
"number": "", "number": "",
@ -241,6 +247,7 @@ class Patient(Model):
'walkin': 'no', 'walkin': 'no',
'departments': _get_departments, 'departments': _get_departments,
'location': _get_default_location, 'location': _get_default_location,
'nation_id': _get_nation,
} }
_sql_constraints=("clinic_patient_key_uniq","unique(name_check,branch_id)","name should be unique"), _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=''): def check_idcard(self,card_type,idcard=''):
res=True res=True
print(card_type , idcard) if not idcard:
return False
if card_type!='identification': if card_type!='identification':
return False return False
if idcard=='/': if idcard=='/':
return True return True
if idcard.isalpha(): if not idcard:
res=False
elif idcard.isalpha():
res=False res=False
elif len(idcard)!=13: elif len(idcard)!=13:
res=False res=False