Edit select sickbad in HD Case (clinic_hd_case)

dev_sa
saharat.i@netforce.co.th 2017-11-23 11:28:14 +07:00
parent 54af83fcfa
commit 00c79ae4b4
2 changed files with 9 additions and 6 deletions

View File

@ -3,7 +3,7 @@
<field name="name"/> <field name="name"/>
<field name="date"/> <field name="date"/>
<field name="patient_id"/> <field name="patient_id"/>
<field name="image" preview="1"/> <!--<field name="image" preview="1"/>-->
<field name="department_id"/> <field name="department_id"/>
<field name="branch_id"/> <field name="branch_id"/>
<field name="note"/> <field name="note"/>

View File

@ -11,18 +11,19 @@ class SickBed(Model):
for obj in self.browse(ids): for obj in self.browse(ids):
hd_case=None hd_case=None
patient_id=None patient_id=None
image=None #image=None
date='' date=''
set_active_user(1) #FIXME permission denined because of department of patient set_active_user(1) #FIXME permission denined because of department of patient
if obj.hd_cases: if obj.hd_cases:
hd_case=sorted(obj.hd_cases, key=lambda a: a.id)[-1] #hd_case=sorted(obj.hd_cases, key=lambda a: a.id)[-1]
hd_case=obj.hd_cases[-1]
patient=hd_case.patient_id patient=hd_case.patient_id
patient_id=patient.id patient_id=patient.id
image=patient.image #image=patient.image
date=hd_case.date date=hd_case.date
res[obj.id]={ res[obj.id]={
'patient_id': patient_id, 'patient_id': patient_id,
'image': image, #'image': image,
'date': date, 'date': date,
} }
set_active_user(get_active_user()) set_active_user(get_active_user())
@ -34,7 +35,7 @@ class SickBed(Model):
'hd_cases': fields.One2Many("clinic.hd.case",'sickbed_id','HDCases'), 'hd_cases': fields.One2Many("clinic.hd.case",'sickbed_id','HDCases'),
'company_id': fields.Many2One("company","Company"), 'company_id': fields.Many2One("company","Company"),
'patient_id': fields.Many2One("clinic.patient","Lasted Patient",function="_get_all",function_multi=True,domain=[['state','=','admit']]), 'patient_id': fields.Many2One("clinic.patient","Lasted Patient",function="_get_all",function_multi=True,domain=[['state','=','admit']]),
'image': fields.File("Image",function="_get_all",function_multi=True), #'image': fields.File("Image",function="_get_all",function_multi=True),
'date': fields.Date("Lasted Date",function="_get_all",function_multi=True), 'date': fields.Date("Lasted Date",function="_get_all",function_multi=True),
"state": fields.Selection([("available","Available"),("not_available","Not Available")],"Status"), "state": fields.Selection([("available","Available"),("not_available","Not Available")],"Status"),
'sequence': fields.Integer("Sequence"), 'sequence': fields.Integer("Sequence"),
@ -44,6 +45,8 @@ class SickBed(Model):
'active': fields.Boolean("Active"), 'active': fields.Boolean("Active"),
} }
_order="name desc"
def _get_branch(self,context={}): def _get_branch(self,context={}):
user_id=get_active_user() user_id=get_active_user()
staffs=get_model("clinic.staff").search_browse([['user_id','=',user_id]]) staffs=get_model("clinic.staff").search_browse([['user_id','=',user_id]])