I have a list of documents (knowledge), I have my views where I filter these document by 'parent_id'. I wanted to know if there's a way to have a domain/filter that will show me:
- Only the newest document with parent_id='1'
- All the document with parent_id='1' excluding the newest.
Ordering and result limiting are both separate parts of the search function, unrelated to domain. Check the technical memento for the search() method on page 4: https://www.openerp.com/files/memento/OpenERP_Technical_Memento_v0.7.4.pdf
You'll have to put it into a separate function to generate the proper search result, but it would look something like this:
# newest_id will be a list of length 1, not an integer newest_id = self.search(cr, uid, [('parent_id','=',1)], limit=1, order='id desc')
Once you have the id of the newest record, you can difference that from the unlimited list of IDs after doing another search without the limit.
other_ids = self.search(cr, uid, [('parent_id','=',1)], limit=1, order='id desc') other_ids = other_ids - newest_id
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
|Asked: 10/14/13, 3:57 AM|
|Seen: 1019 times|
|Last updated: 3/16/15, 8:10 AM|