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 generate sequence number when sequence number reached to 100 then it will start to 1 ?

on 12/11/14, 7:20 AM 490 views

Hello Team,

I generate the sequence number though code, but the problem is when sequence number is 100 then automatically start with Zero(0), How?????

Please any one guide me to do this through code not in Front End.

Thanks to all in Advance,

I am waiting for ur response....




| 5 4 7
Bikaner, India

OpenERP Devloper at SunARC Technology

On 12/11/14, 8:07 AM

Try the below code:
def create(self, cr, uid, vals, context=None):
    sequence_obj = self.pool.get('ir.sequence')
    if vals.get('seq_field') == 100:
        seq_id = sequence_obj.search(cr, uid, [('code', '=', 'model.name')])
        if seq_id:
            sequence_obj.write(cr, uid, seq_id, {'number_next': 1})
    vals['seq_field'] = self.pool.get('ir.sequence').get(cr, uid, 'model.name') or '/'
    return super(class_name, self).create(cr, uid, vals, context=context 

Hi Prakash, Thank you very much.

on 12/11/14, 8:43 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

1 follower(s)


Asked: 12/11/14, 7:20 AM
Seen: 490 times
Last updated: 3/16/15, 8:10 AM