This is my code-------
class account_voucher(osv.Model):
_inherit = "account.voucher"
_columns={
'sequence_number':fields.char('Sequence Number'),
}
def create(self, cr, uid, vals, context=None):
vals['sequence_number'] = self.pool.get('ir.sequence').get(cr, uid,'account.voucher')
return super(account_voucher, self).create(cr, uid, vals, context=context)
_defaults={
'sequence_number': lambda obj, cr, uid, context: ' /',
}
account_voucher()
=============================
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<!-- Sequences for loan_id -->
<record id="seq_cloan_code_inh1" model="ir.sequence.type">
<field name="name">SEQ ID</field>
<field name="code">account.voucher</field>
</record>
<record id="seq_cloan_code_inh2" model="ir.sequence">
<field name="name">SEQ ID</field>
<field name="code">account.voucher</field>
<field name="prefix">SEQ</field>
<field name="padding">2</field>
</record>
</data>
</openerp>
hope this will helps: https://learnopenerp.blogspot.com/2020/08/generate-create-sequence-number-odoo.html