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

How to generate Unique ID in OpenERP

By
More9ike
on 6/7/13, 9:48 AM 1,635 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

0

patrick

--patrick--
1958
| 5 4 7
Baarn, Netherlands
--patrick--
patrick
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.

Example:

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

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

patrick
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

More9ike
on 6/10/13, 8:14 AM

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

0 follower(s)

Stats

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