Odoo Help

Welcome!

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

0

Sequence (Auto Increment No.)

By
Ken Kasai
on 2/2/15, 1:26 AM 1,357 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

Sequences:

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



--
Regards,

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
2

Ankit H Gandhi(AHG)

--Ankit H Gandhi(AHG)--
996
| 5 3 6
Rajkot, 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"?>
<openerp>
    <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>

        <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>
        </record>

    </data>
</openerp>

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    

Regards,

Ankit H Gandhi

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 2/2/15, 1:26 AM
Seen: 1357 times
Last updated: 3/16/15, 8:10 AM