Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1 Відповісти
3622 Переглядів

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

 

Аватар
Відмінити
Найкраща відповідь

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.