El 03/07/17 a les 10:04, Khurram Shahzad ha escrit:
Dear Sergi,
On Mon, Jul 3, 2017 at 12:31 PM, Sergi Almacellas Abellana
<[email protected] <mailto:[email protected]>> wrote:
El 03/07/17 a les 07:43, Khurram Shahzad ha escrit:
Dear All,
I am trying to sort the searched records using following code:
roundings = PatientRounding.search([
('name', '=', self.name <http://self.name>
<http://self.name>),
], order=[('evaluation_start', 'DESC')])
But, I am not getting the results sorted on 'evaluation_start'
field. Infact, the 'order' clause is not affecting the sorting
of searched records!
Is this the correct way of sorting the searched records? Or
there is some other way of searching for a model and retuning
the sorted results?
Is the correct way.
Which type of field is the evaluation_start? Is it a functional one?
Have you implemented some order_ function to override it?
It is not a functional field. And, it is defined as following:
class PatientRounding(ModelSQL, ModelView):
'Patient Rounding'
__name__ = 'gnuhealth.patient.rounding'
STATES = {'readonly': Eval('state') == 'done'}
name = fields.Many2One('gnuhealth.inpatient.registration',
'Registration Code', required=True, states=STATES)
code = fields.Char('Code', states=STATES)
health_professional = fields.Many2One('gnuhealth.healthprofessional',
'Health Professional', readonly=True)
evaluation_start = fields.DateTime('Start', required=True,
states=STATES)
Do we need to implement and override order_ function? How can that be
done for the above class where I want to sort on 'evaluation_start', the
results returned by 'search' method. Please note this sort column is
different than that defined in '__setup__()' class method.
No it's not required, but it can be used to customize the order, and
this can break the order if not done correctly.
I can not see any other reason to not make it work.
--
Regards,
Khurram.
--
You received this message because you are subscribed to the Google
Groups "tryton" group.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tryton/CAM3N3CwauqXQcLC_NLwx3OKjXLus6DhS4Vem8Q2yUcMw-SqsMA%40mail.gmail.com
<https://groups.google.com/d/msgid/tryton/CAM3N3CwauqXQcLC_NLwx3OKjXLus6DhS4Vem8Q2yUcMw-SqsMA%40mail.gmail.com?utm_medium=email&utm_source=footer>.
--
Sergi Almacellas Abellana
www.koolpi.com
Twitter: @pokoli_srk
--
You received this message because you are subscribed to the Google Groups
"tryton" group.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tryton/3fc40af9-8f98-e7a0-f7f9-8b10a33d63fe%40koolpi.com.