El 03/05/17 a les 16:55, Carlos Ibrahim Arias ha escrit:
I created the model Z_MecialHistory to store information of the patient
(/date, patient and healthprofessional/) and it is related to the model
PatientData. The point is that, as Albert said, I need to access to the
information in the model PatientEvaluation.
After adding the function field Albert recommended to the model
PatientEvaluation
....
|
z_medical_history
=fields.Function(fields.Many2Many('gnuhealth.z_medical_history',
None,None,'Historial Medico del Paciente'),'get_z_medical_history')
|
... I added the following function to PatientEvaluation model guessing
that I had to use the current patient ....
|
defget_z_medical_history(self,name):
pool =Pool()
Patient=pool.get('gnuhealth.patient')
returnPatient.z_medical_history
|
But it doesnt work... I dont really understant how to the get function
should be coded to worrk...
You should return the list of ids of the related record. So it will be
something like:
def get_z_medical_history(self, name):
pool = Pool()
History = pool.get('...')
return [x.id for x in History.search([('patient', '=', self.id)])
Hope it helps.
--
Sergi Almacellas Abellana
www.koolpi.com
Twitter: @pokoli_srk
--
You received this message because you are subscribed to the Google Groups
"tryton-dev" group.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tryton-dev/2c1e7d40-5ad2-7d26-d4bf-de6d8c850fad%40koolpi.com.