Odoo Help


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.


how to make a sequence field renumber lines according to the current filter automatically

Tarek Mohamed Ibrahim
on 8/30/15, 12:27 PM 376 views

I created a sequence field as a function field to show the number of records in browse starting from '1', regardless the 'id' value of the record.

I used the following code

    def _get_sequence(self, cr, uid, ids, fields, args, context=None):
        line_o = self.pool.get('budget.transaction.line')
        for o in self.browse(cr,uid,ids):
            res[o.id] = 1+line_o.search_count(cr,uid,[('id','<',o.id)])
        return res
    _columns = {
ondelete='cascade', select=True, required=True), 'sequence': fields.function(_get_sequence,string='Sequence',type='integer', help="Gives the sequence order when displaying a list of lines."),

The issue with me now is that I need this numbering to be recalculated if I changed the filter of applied on the browse from the advanced search option. How to achieve this. Any help is appreciated.


Axel Mendoza

--Axel Mendoza--
| 6 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 8/30/15, 10:51 PM

You need to declare a field preferably a dummy that no have a calculation method or you just simply forget about it, then you need to override the methods, read and read_group to assign the value to each record that you will display, a little more tricky is the read_group that will apply when you "group by" the data. The override methods need to assign the value of the field by an increment of the sequence value

Also you need to take pagination into account

Axel Mendoza
on 8/31/15, 10:47 AM

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)


Asked: 8/30/15, 12:27 PM
Seen: 376 times
Last updated: 9/4/15, 3:04 PM