Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
3635 Vizualizări

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

 

Imagine profil
Abandonează
Cel mai bun răspuns

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 

Imagine profil
Abandonează
Autor

Hi Prakash, Thank you very much.