Skip to content

[ADD] hr_employee_fs_folder: documents folder per employee, shared read-only - #2229

Draft
davidwul wants to merge 1 commit into
18.0from
18.0-hr-employee-fs-folder
Draft

davidwul wants to merge 1 commit into
18.0from
18.0-hr-employee-fs-folder

Conversation

@davidwul

Copy link
Copy Markdown
Contributor

Purpose

HR wants documents for each employee in Google Drive, and each employee must be able to read the documents meant for them (salary certificate, payslips…) and only those.

What it does

New module hr_employee_fs_folder (depends on hr, OCA fs_folder, queue_job; nothing from the Swiss repositories, so any office can install it):

<id> - <name>/      HR only (contract, evaluations...)
  Shared/           HR and the employee, read only
  • HR officers: HR Documents tab on the employee, showing the whole folder (Shared/ included).
  • Employees: Employees > My Documents opens their own Shared/ folder, read only (list, preview, download). fs_folder roots each folder, so .. cannot reach the HR folder.
  • Why a dedicated model (hr.employee.shared.folder): fs_folder checks access on the record carrying the field. Employees cannot read hr.employee (HR only), and every employee can read every hr.employee.public and every res.users, so none of them can carry a folder only its employee may see. The new model has a record rule: own folder for employees, allowed companies for HR officers (multi-company: CH / PL).
  • Creation: a queue job creates both folders when an employee is created (only when a storage is linked to the fields), or the action Create Documents Folders on existing employees. The widget's Create Folder button does the same.
  • Renaming: the folder is renamed (queue job) when the employee is renamed; the link of the shared folder follows.
  • Same fs_folder workaround as partner_fs_folder ([ADD] partner_fs_folder: documents folder on partners (Google Drive via fs_folder) #2223): folder creation checks write access on the record, then uses sudo, because fs_folder reads fs.storage (credentials) with the user's rights.
  • Widget: the fs_folder widget ignores readonly. A small patch hides the buttons that change the folder (add, upload, drop, rename, delete, unlink) when the field is read only; the server refuses them anyway (employees have read-only access). Candidate for OCA.

Google Drive

Separate Shared Drive "HR", service account odoo-hr-* as Content manager, only HR as members (Contributor): employees access their documents through Odoo only. Separate rclone serve webdav (another port and password) and an hr_docs storage linked to both fields (see readme/CONFIGURE.md).

Tests

  • 11 unit tests on a local storage: creation by an HR officer through the job, employee reads only their own shared folder (not the HR folder, not another employee's, cannot upload, cannot escape with ..), My Documents action, renaming, action on existing employees, widget button, HR officer of another company refused.
  • Checked over HTTP as a demo employee: My Documents menu, own shared folder listed, HR folder refused; the backend JS bundle builds with the widget patch (each template xpath matches one node).
  • Not yet checked in a browser: the hidden buttons.

Staging

To be put on stage with the usual process, after the Drive / rclone setup for HR.

🤖 Generated with Claude Code

…ad-only

Each employee gets a folder on an external file system (fs_folder, e.g. a
Google Drive Shared Drive served over WebDAV by rclone):

    <id> - <name>/      HR only
      Shared/           HR and the employee, read only

- HR officers see the whole folder in the HR Documents tab of the employee.
- Employees see their own Shared folder in Employees > My Documents. It is on
  its own model with a record rule: employees cannot read hr.employee, and
  every employee can read every hr.employee.public and res.users.
- Folders are created by a queue job with the employee (when a storage is
  configured) or with an action on existing employees, and renamed with the
  employee.
- The fs_folder widget hides the actions that change the folder when the field
  is read only.

Assisted-by: claude-opus-5-5, medium, claude-code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant