Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
1 Antworten
37580 Ansichten

Hi Friends,

I am working odoo v 7.0.I have search by some condition from account_invoice table and filtered some records.I have got some ids of records.Now i have to order those ids by date_invoice field.How it will be resolved? . Please help me in this situation.Thanks in advance.

Avatar
Verwerfen
Beste Antwort

Hi @vadivel

If you are calling search by yourself you could pass the order that you need like:

posted_depreciation_line_ids = depreciation_lin_obj.search(cr, uid, [('asset_id', '=', asset.id), ('move_check', '=', True)],order='depreciation_date desc')

I include the method doctring that parse and generate the order by based on the order argument of the search method:

    def _generate_order_by(self, order_spec, query):
"""
Attempt to consruct an appropriate ORDER BY clause based on order_spec, which must be
a comma-separated list of valid field names, optionally followed by an ASC or DESC direction.

:raise" except_orm in case order_spec is malformed
"""
Avatar
Verwerfen
Autor

Thank you so much @Axel Mendoza..This query saves lots of time..

Happy to help you, could you accept the answer too?

Autor

Yes Axel..I did.Also one more help.Can we define sorting by more than one fields.Need to add one more field in order.Is it possible.?

Yes, see the answer update for more. The accept on the question is the check mark bellow the upvote

Did you see it?

Verknüpfte Beiträge Antworten Ansichten Aktivität
2
März 15
8894
4
Juli 17
21773
3
März 15
4900
0
März 15
5256
0
März 15
3513