Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to sort ids by date wise, which is resulted ids from search method?

By
vadivel
on 12/5/15, 1:54 AM 556 views

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.

1

Axel Mendoza

--Axel Mendoza--
10228
| 7 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 12/5/15, 2:41 AM

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

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

vadivel
on 12/5/15, 2:55 AM

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

Axel Mendoza
on 12/5/15, 3:00 AM

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

vadivel
on 12/5/15, 3:38 AM

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

Axel Mendoza
on 12/5/15, 3:48 AM

Did you see it?

Axel Mendoza
on 12/5/15, 7:02 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 12/5/15, 1:54 AM
Seen: 556 times
Last updated: 4/20/16, 3:18 AM