How to make the field otherid unique in HR

Asked by Bushair

Hi,

How to make the field Other ID in the HR->New Employee -> Personal Information unique.

Right now ,the code in hr.py is as shown below

'otherid': fields.char('Other ID', size=32),

I would like to make this ID as unique to identify the Employees...

How to achieve this?

Question information

Language:
English Edit question
Status:
Solved
For:
Odoo Server (MOVED TO GITHUB) Edit question
Assignee:
No assignee Edit question
Solved by:
Cristian Salamea
Solved:
Last query:
Last reply:
Revision history for this message
Bushair (bushairka) said :
#1

Hello,
Can anyone tell me how to make a field ,auto increment in OpenERP.

I would like to make this field ,other ID as autoincrement variable...
means which will be automatically increment whenever i create a new Employee.

thanks

Revision history for this message
Cristian Salamea (ovnicraft) said :
#2

for first question you can write a _sql_constraints like this :

_sql_constraints = [('name_uniq','unique(name)', 'Field name must be unique!')]

Revision history for this message
Best Cristian Salamea (ovnicraft) said :
#3

For the second question you can write in your field with a related sequence (ir.sequence object) this is used in many documents: orders, invoices, account entries, etc.

You can check the code and try it.

Regards,

Revision history for this message
Bushair (bushairka) said :
#4

Thank you very much for the answer.