60 lines
1.9 KiB
Markdown
60 lines
1.9 KiB
Markdown
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
|
|
------------
|
|
|
|
1. Copy ``hr_employee_pin`` into your custom addons path.
|
|
2. Update the addons list in Odoo (Settings → Activate Developer Mode → Update App List).
|
|
3. Install **Employee PIN Generator** from the Apps menu.
|
|
4. 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:
|
|
|
|
1. Open an employee record.
|
|
2. Go to the **Private Information** tab.
|
|
3. Find the *Employee PIN* section and click **Regenerate PIN**.
|
|
4. Confirm in the dialog.
|
|
5. A success notification will show the new PIN.
|
|
|
|
Author
|
|
------
|
|
|
|
Suherdy Yacob
|
|
|
|
License
|
|
-------
|
|
|
|
LGPL-3
|