1.9 KiB
1.9 KiB
Employee PIN Generator
.. contents:: :local: :depth: 1
Overview
This Odoo 19 module automatically assigns a unique, randomly generated 6-digit PIN to every employee record. The PIN is enforced to be globally unique across all companies in the same Odoo database via a SQL UNIQUE constraint.
Features
- Auto-generates a 6-digit numeric PIN when a new employee is created.
- PIN uniqueness is enforced at the database level (UNIQUE constraint on
employee_pin). - No two employees — even in different companies — can share the same PIN.
- A Regenerate PIN button is available on the employee form (Private Information tab) for HR managers and users.
- A confirmation wizard is shown before replacing the current PIN, displaying the existing value.
Technical Details
- Model extended:
hr.employee - New field:
employee_pin(Char, size 6, unique) - New transient model:
hr.employee.regenerate.pin.wizard - PIN generation retries up to 1,000 times to avoid collision in a crowded pool.
Installation
- Copy
hr_employee_pininto your custom addons path. - Update the addons list in Odoo (Settings → Activate Developer Mode → Update App List).
- Install Employee PIN Generator from the Apps menu.
- Existing employees will NOT receive a PIN automatically — use the Regenerate PIN button on each record, or run a one-time migration script.
Usage
When creating a new employee the PIN is generated automatically and shown in the Private Information tab under the Employee PIN section.
To regenerate the PIN:
- Open an employee record.
- Go to the Private Information tab.
- Find the Employee PIN section and click Regenerate PIN.
- Confirm in the dialog.
- A success notification will show the new PIN.
Author
Suherdy Yacob
License
LGPL-3