Re: [tryton] Sorting the searched records

2017-07-03 Thread Sergi Almacellas Abellana

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 
> 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 
),
  ], 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 
.



--
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.


Re: [tryton] Sorting the searched records

2017-07-03 Thread Khurram Shahzad
Dear Sergi,

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


Re: [tryton] Sorting the searched records

2017-07-03 Thread Sergi Almacellas Abellana

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 ),
 ], 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?




--
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/099b8502-3039-e862-67f5-096970fa5fbd%40koolpi.com.


Re: [tryton] Sorting the searched records

2017-07-03 Thread Jean Cavallo
Hi,

2017-07-03 7:43 GMT+02:00 Khurram Shahzad :

> roundings = PatientRounding.search([
> ('name', '=', self.name),
> ], order=[('evaluation_start', 'DESC')])
>

What's the printed output of calling the search with the query=True
parameter ?

Jean Cavallo
*Coopengo*

-- 
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/CAAc4%2BPakLWD5TVfvoJKTAm6bXx0X01VeRS%2BZme0P%2BLfjoqqCtA%40mail.gmail.com.


[tryton] Sorting the searched records

2017-07-02 Thread Khurram Shahzad
Dear All,

I am trying to sort the searched records using following code:

roundings = PatientRounding.search([
('name', '=', 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?

-- 

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/CAM3N3Cxc%3DAkDLLykiuh%2ByYKMEp3xg81ZnCHdwbqEfghp5DRcSA%40mail.gmail.com.