Skip to content

Add RBAC permission scripts (roles, field-levels, scoping, cleanup) - #9

Open
hamad-clustox wants to merge 4 commits into
feature/hr-setup-and-attendancefrom
feature/hr-rbac-permissions
Open

hamad-clustox wants to merge 4 commits into
feature/hr-setup-and-attendancefrom
feature/hr-rbac-permissions

Conversation

@hamad-clustox

Copy link
Copy Markdown
Collaborator

Stacked on #8 (adds setup/permissions/, which builds on the setup/ folder introduced there). Base retargets to develop once #8 merges.

What this adds

Repeatable, idempotent scripts that reproduce the entire permission model on a fresh Frappe HR site. Each is a Frappe script run via bench execute hrms.<module>.run; see setup/permissions/README.md for run order.

Layer Script Effect
Roles + DocType matrix apply_rights_matrix.py + rights_matrix.json Creates Team Lead / Department Head / CEO/COO / IT User / Admin User; applies the 38-DocType rights matrix from HR's sheet. System Manager keeps full access; export/print/import withheld from other roles.
Field-level confidentiality apply_field_levels.py Sensitive Employee fields → Permission Level 1 (DOB, mobile, personal email, addresses, marital status, CNIC, CNIC expiry) and Level 2 (bank name/AC/IBAN). L1 → HR + CEO/COO; L2 → + Accounts. Only Administrator bypasses.
Record scoping scope_employees.py Per-doctype User Permissions restrict regular employees to their own leave/attendance/salary/etc.; directory + org chart stay visible. Broad-role users skipped.
Role assignment assign_roles.py Adds roles to specific logins from a private JSON mapping (no PII in repo — see role_assignments.example.json).
Org placeholder set_reports_to.py Flat reports_to so the org chart renders (placeholder for real lines).
Role cleanup disable_roles.py Disables (reversibly) 25 unused ERPNext business-module roles; optionally strips them off over-provisioned accounts.

Safety / privacy

  • No secrets or employee PII committed — real employee→role mapping stays in git-ignored config; only role_assignments.example.json (placeholder codes) ships.
  • All scripts are idempotent and safe to re-run on a site that already has data.
  • Cleanup disables, never deletes, roles (reversible; avoids the bench migrate recreation trap).

Not included (documented as follow-ups in the README)

  • Manager team-scope — depends on real reporting lines replacing the placeholder.
  • Employee self-view of own confidential fields — would need a self-service field exception.

🤖 Generated with Claude Code

hamaadrana and others added 2 commits August 31, 2026 23:23
Repeatable, idempotent setup/permissions/ scripts that build the whole
permission model on a Frappe HR site:

- apply_rights_matrix.py + rights_matrix.json — 5 roles (Team Lead,
  Department Head, CEO/COO, IT User, Admin User) and the 38-DocType rights
  matrix from HR's permission sheet
- apply_field_levels.py — sensitive Employee fields to Permission Level 1
  (DOB/CNIC/contact) and 2 (bank), granted only to HR/CEO/Accounts
- scope_employees.py — User Permissions restricting employees to their own
  transactional records; directory/org chart stay visible
- assign_roles.py — role assignment from a private JSON mapping (no PII in
  repo; see role_assignments.example.json)
- set_reports_to.py — org-chart reporting placeholder
- disable_roles.py — declutter unused ERPNext business-module roles

No secrets or employee PII are committed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Routes plus-addressed support email to the right HD Team so the existing
per-team round-robin assigns an agent:
  support+it@       -> IT Team
  support+accounts@ -> Accounts Team
  support+admin@    -> Admin Team

- hrms/helpdesk_router.py: route_tickets() reads the recipient tag from the
  incoming email's Communication and sets the ticket's agent_group. No-op where
  Helpdesk isn't installed.
- hooks.py: registered under scheduler_events['all'] so bench migrate wires it
  up and the scheduler runs it (server-script Scheduler Events don't register on
  this build). Runs OUTSIDE the email-receive transaction on purpose — routing
  from a Communication doc-event breaks all inbound email.
- setup/helpdesk/README.md: routing, registration, and the SLA/FRT + Jira-loop
  findings from the IT review.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
hamaadrana and others added 2 commits September 2, 2026 18:59
Two signature-verified endpoints (hrms/slack_helpdesk.py):
  slack_command  -> opens a modal (subject, description, team, priority)
  slack_interact -> creates the HD Ticket on the chosen team; the existing
                    round-robin assigns an agent; DMs the reporter the number

Secrets (slack_signing_secret, slack_bot_token) live in site config, not code.
Setup guide: setup/helpdesk/SLACK_SETUP.md. MVP — pending live Slack test.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add Helpdesk email-tag team routing (scheduled job)
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.

2 participants