Odoo Help


How to generate sequence number when sequence number reached to 100 then it will start to 1 ?

on 12/11/14, 7:20 AM 814 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 Developer 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

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

1 follower(s)


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