Restrict sales users to their own customers
Use User Permissions when a sales user must work only with their own customers and leads. A role decides which DocTypes the user can open. A User Permission limits which documents of those DocTypes the user can see.
A Sales Person record does not restrict access. It is for sales credit, targets, and commission only.
Prerequisites
- System Manager role, to manage users and User Permissions.
- The sales user exists as a System User.
- The customers and leads exist.
Give the user the Sales User role
- Open the user.
- On Roles & Permissions, select Sales User.
- Add other roles only if the user needs their actions. Do not add Sales Manager only to show a workspace.
- Save.
Allow each customer
Create one User Permission for each customer in the user's portfolio:
- Open the User Permission list and select Add User Permission.
- In User, select the sales user.
- Set Allow to Customer.
- In For Value, select the customer.
- Keep Apply To All Document Types selected.
- Save. Repeat for each customer.
Quotations, Sales Orders, Delivery Notes, and Sales Invoices link to a customer. With Apply To All Document Types selected, the customer restriction also applies to those documents. You do not need a User Permission for each order.
If you clear Apply To All Document Types, the permission applies only to the DocType in Applicable For.
Allow each lead
A lead is not a customer, so customer permissions do not cover leads. Create one User Permission for each lead with Allow set to Lead. When a lead becomes a customer, add a customer permission for the new customer.
Use a territory for large portfolios
If your customers and leads are divided by region, create one User Permission with Allow set to Territory instead of one for each customer. A parent territory also allows its child territories, unless you select Hide Descendants.
Use a territory or a customer group only when it matches the real access boundary. A customer group made for pricing usually does not.
Check the result
- Open the user and select Permissions > View Permitted Documents.
- Check Customer, Lead, Quotation, Sales Order, Delivery Note, and Sales Invoice.
- Log in as a test user with the same roles and permissions. Confirm that unrelated customers do not appear in lists and reports.
Do not test with a System Manager or Administrator account. These accounts are not restricted in the same way.
Documents with an empty customer
If Apply Strict User Permissions is cleared in System Settings, the user can see documents whose restricted link is empty, for example a Lead without a territory. If it is selected, ERPNext hides those documents. This is a system-wide setting, so test its effect on all teams.
Troubleshooting
| Problem | Cause and fix |
|---|---|
| The user still sees every customer | A broader permission exists, for example a parent territory. Or the role does not apply User Permissions. Check the user's User Permission list. |
| The user cannot open any sales document | The role has no read access, or the document's customer is not allowed. |
| Assigned leads are missing | Create Lead permissions. Customer permissions do not cover leads. |
| A report shows too much data | Test the report as the restricted user. A custom report may not apply permissions. |
| A sales manager cannot see the team's customers | The Sales Person tree does not grant access. Give the manager broader permissions. |