Dear Sergi,

On Mon, Jul 3, 2017 at 12:31 PM, Sergi Almacellas Abellana <[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>),
>>              ], 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.
-- 

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.

Reply via email to