Odoo Help


How to generate Unique ID in OpenERP

on 6/7/13, 9:48 AM 2,786 views

Hello all, please i have a model that needs the ID for each applicant to be generated automatically when the document is approval. I want the ID for each applicant to be generated uniquely when the form is approve. The sample fields in the model are: Applicant ID (to be generated when the form is approved), Applicant name. etc. Please how do I achieve that? Thanks




| 5 4 7
Baarn, Netherlands
On 6/7/13, 12:28 PM

You have to use the same method as generating a unique order number. Or just use the id of the record. That should be unique anyway.

Are there any requirements for the Applicant ID (needs to be at least x long, must be in the following format: XXX-ID-(A or B), ... ) Depending on the answers of the above question, you can use the record ID, or use ir.sequences.


stockpick = self.pool.get('stock.picking').browse(.....)
name = sequence_obj.get('stock.picking.%s'%(stockpick.type))

Yes the Applicant ID will start with A and is nine in length. But i don't want to use sequence because when the record is deleted and a new record is created, sequence number won't start from the beginning again. I don't want the number to be generated when creating a new record, I want it generate after the record has been approved. Thanks

on 6/7/13, 1:24 PM

Than you have to create a table with used IDs, and when you delete an applicant, mark the ID in your table as free, or remove it from the table. It is possible to add the action of generating the applicant ID when you approve the record. At that moment you use the sequence. Maybe unpolite, but why do you want to reuse applicantID? Than different applicants can have the same ID (although not at the same moment in time)..... Than the whole purpose of of an ID is gone.

on 6/7/13, 8:08 PM

Please am new to OpenERP! please can you give me an example on how to create the table with applicant ID? and i do not want to have the ID fro the same applicant. I want the ID to be uniqued for each applicant. Thanks

on 6/10/13, 8:14 AM

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

0 follower(s)


Asked: 6/7/13, 9:48 AM
Seen: 2786 times
Last updated: 3/16/15, 8:10 AM