Odoo Help


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

Tarek Mohamed Ibrahim
on 8/30/15, 12:27 PM 713 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
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

About This Community

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


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)


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