Odoo Help


Sequence (Auto Increment No.)

Ken Kasai
on 2/2/15, 1:26 AM 2,931 views

I created a sequence in Settings > Sequences and Identifiers > Sequences also in Sequence Codes. And I want to link the sequence to my custom field (x_applicant_num) in HR Applicant so that I could have an auto increment field for each applicant. anyone can help? thanks


Sequence Codes:

name: Applicantion No.

code: applicant_no


name: applicant_num

sequence type: Applicant No.

number padding:5

next number: 1

auto increment: 1






thank you for the answer. However, Im a little confuse. Do I need to create a field or an object in Settings > Database Structure > Models / Fields for the Auto Increment Field?

On Mon, Feb 2, 2015 at 7:30 PM, Ankit Gandhi <er.ankitgandhi2013@gmail.com> wrote:

A new answer for Sequence (Auto Increment No.) has been posted. Click here to access the post.

Ankit Gandhi
Sent by Odoo S.A. using Odoo about Forum Post Sequence (Auto Increment No.)


Ken Kasai, Software Engineer
NABI Computer Systems
Tel     : 632-985-6755
Fax    : 632-854-2643
skype/ym id: kenkasai222
Ken Kasai
on 2/3/15, 12:02 AM

Ankit H Gandhi(AHG)

--Ankit H Gandhi(AHG)--

| 6 5 6
Baroda, India
--Ankit H Gandhi(AHG)--

Learning Python..

Ankit H Gandhi(AHG)
On 2/2/15, 6:30 AM

Hello Ken Kasai,

This below code may be very helpfull.

create new .xml file

<?xml version="1.0" encoding="utf-8"?>
    <data noupdate="1">
        <record id="test_base_sequence_type" model="ir.sequence.type">
            <field name="name">Test Base Sequence</field>
            <field name="code">test.base.code</field>

        <record id="test_base_sequence" model="ir.sequence">
            <field name="name">Test Base Sequence</field>
            <field name="padding">5</field>
            <field name="prefix">TB/%(year)s/</field>
            <field name="suffix">/Ankit</field>
            <field name="code">test.base.code</field>
            <field name="implementation">no_gap</field>


and create new .py file

class test_base(osv.Model):

      _name = 'test.base'

     _columns = {

           'code' : fields.char("Code", size=25, readonly=True)


    def create(self, cr, uid, vals, context=None):
        sequence = self.pool.get('ir.sequence').get(cr, uid, 'test.base.code')
        vals['code'] = sequence
        res = super(test_base, self).create(cr, uid, vals, context=context)
        return res

if you find this answer helpful, please give me a thumbs up vote    


Ankit H Gandhi

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: 2/2/15, 1:26 AM
Seen: 2931 times
Last updated: 3/16/15, 8:10 AM