Skip to Content
Menu
Dette spørgsmål er blevet anmeldt
1 Svar
3623 Visninger

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

 

Avatar
Kassér
Bedste svar

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 

Avatar
Kassér
Forfatter

Hi Prakash, Thank you very much.