show name department

conv_bal
watcha.h 2015-03-14 00:20:48 +07:00
parent edf9f83901
commit 03116925db
5 changed files with 26 additions and 29 deletions

View File

@ -11,7 +11,7 @@
<field name="name"/>
<field name="type_id"/>
<!--<field name="branch_id"/>-->
<field name="department_id"/>
<field name="department_names"/>
<field name="doctor_id"/>
<!--<field name="image" preview='1'/>-->
</list>

View File

@ -10,10 +10,6 @@
<field name="number"/>
<field name="name"/>
<field name="type"/>
<field name="location"/>
<!--<field name="branch_id"/>-->
<!--<field name="department_id"/>-->
<!--<field name="level_id"/>-->
<!--<field name="categ_id"/>-->
<field name="department_names"/>
<field name="image" preview="1"/>
</list>

View File

@ -78,6 +78,12 @@ class Patient(Model):
res[obj.id]=','.join([code for code in dpt_codes if code])
return res
def _get_department_names(self,ids,context={}):
res={}
for obj in self.browse(ids):
res[obj.id]=','.join([dpt.name for dpt in obj.departments])
return res
_fields={
"number": fields.Char("HN Number",required=True,search=True),
"trt_no": fields.Char("TRT",search=True),
@ -148,6 +154,7 @@ class Patient(Model):
'state': fields.Selection([['admit','Admit'],['dispose','Dispose']],'State'),
'walkin': fields.Selection([['yes','Yes'],['no','No']],"Walk In"),
'departments': fields.Many2Many("clinic.department","Departments"),
'department_names': fields.Text("Departments",function="_get_department_names"),
'location': fields.Char("Location",function="_get_location",store=True), #to filter
}
@ -210,7 +217,7 @@ class Patient(Model):
'departments': _get_departments,
}
_sql_constraints=("clinic_patient_key_uniq","unique(name_check)","name should be unique"),
_sql_constraints=("clinic_patient_key_uniq","unique(name_check,branch_id)","name should be unique"),
_order="reg_date desc"
def check_idcard(self,idcard=''):

View File

@ -150,27 +150,14 @@ class ClinicSetting(Model):
print("Only admin!!")
return
# update
for pt in get_model("clinic.patient").search_browse([]):
dpt=pt.department_id
dpt_ids=set()
for cc in pt.cycles:
dp=cc.department_id
vals={}
if not dp:
vals.update({
'department_id': dpt.id,
})
if (dp.day or "").isdigit():
day=DAYS[int(dp.day)]
vals.update({
'day': day,
})
cc.write(vals)
dp=dp or dpt
dpt_ids.update({dp.id})
dpt_ids=list(dpt_ids)
pt.write({
'departments': [('set',dpt_ids)],
db=get_connection()
res=db.query("select id, day from clinic_patient_cycle")
for r in res:
day=r['day'] or ""
if day.isdigit():
pc=get_model('clinic.patient.cycle').browse(r['id'])
pc.write({
'day': DAYS[int(r['day'])],
})
return
### remove douplicate visit

View File

@ -100,6 +100,12 @@ class Staff(Model):
res[obj.id]=",".join([d.code for d in obj.departments])
return res
def _get_department_names(self,ids,context={}):
res={}
for obj in self.browse(ids):
res[obj.id]=','.join([dpt.name for dpt in obj.departments])
return res
_fields={
'employee_id': fields.Many2One("hr.employee","Employee"),
"number": fields.Char("Number",required=True,search=True),
@ -155,6 +161,7 @@ class Staff(Model):
'branch_id': fields.Many2One("clinic.branch","Branch", search=True),
"partner_id": fields.Many2One("partner","Contact"),
'departments': fields.Many2Many("clinic.department","Departments"),
'department_names': fields.Text("Departments",function="_get_department_names"),
"location": fields.Char("Location",function="_get_location",store=True),
}