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
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
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
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.
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