Erpnext Module Gate
Module licensing and access control for ERPNext SaaS platforms. Control which ERPNext modules users can access based on their purchase or license.
- Author: ZeiadMadboly
- Repository: https://github.com/ZeiadMadboly/erpnext_module_gate
- GitHub stars: 1
- Forks: 4
- License: MIT
- Category: Other
- Maintenance: Minimally Maintained
Install Erpnext Module Gate
bench get-app https://github.com/ZeiadMadboly/erpnext_module_gate
Tags
- access-control
- erpnext
- erpnext-customization
- erpnext-module
- saas
Add the Frappe Gems badge to your README
Maintain Erpnext Module Gate? Paste this into your README:
[](https://frappegems.com/gems/apps/ZeiadMadboly/erpnext_module_gate)
About Erpnext Module Gate
ERPNext Module Gate
Module licensing and access control for ERPNext SaaS platforms
Author: Zeiad Madboly
What is ERPNext Module Gate?
ERPNext Module Gate allows you to sell ERPNext as modular packages. Instead of giving customers access to the entire ERPNext suite, you can control which modules they can access based on their purchase or license.
Key Features
- ✅ Module-based access control - Control which ERPNext modules users can access
- ✅ Automatic role management - Users automatically get the right roles for their licensed modules
- ✅ Workspace filtering - Unlicensed modules are hidden from navigation
- ✅ Custom module support - All custom modules (non-ERPNext) are accessible by default
- ✅ Secure - Even System Managers cannot bypass module restrictions
- ✅ Administrator bypass - Full access for Administrator account
- ✅ Easy integration - Works seamlessly with ERPNext SaaS registration workflows
Quick Start
1. Installation
cd /path/to/your/bench
bench get-app erpnext_module_gate
bench install-app erpnext_module_gate
bench migrate
2. Configure Licensed Modules
Option A: Via Registration Form (Recommended)
When users register through your SaaS platform, they can select which modules they want. The system automatically configures their site.
Option B: Manual Configuration
# Set specific modules
bench --site [site_name] execute erpnext_module_gate.erpnext_module_gate.set_modules.set_modules
# Or grant full access (no restrictions)
bench --site [site_name] execute erpnext_module_gate.erpnext_module_gate.set_all_modules.set_all
3. Verify It Works
<pre><code class="bash language-bash"># Run automated tests
bench --site [site_name] execute erpnext_module_gate.erpnext_module_gate.test_module_enforcement.run_tests
</code></pre>
How It Works
For End Users
- User registers and selects modules (or you configure them)
- User logs in - System automatically assigns correct roles
- User sees only licensed modules in the workspace navigation
- User can only access doctypes from licensed ERPNext modules
- Custom modules are always accessible regardless of licensing
For System Administrators
- ✅ Can manage users and permissions within licensed modules
- ✅ Can access Role Permission Manager (but only for licensed ERPNext modules)
- ✅ Can access all custom modules (non-ERPNext) without restrictions
- ❌ Cannot access unlicensed ERPNext module doctypes
- ❌ Cannot assign unlicensed ERPNext module roles
- ❌ Cannot bypass restrictions through any method
For Platform Administrators
- ✅ Full access to everything (Administrator account)
- ✅ Can modify
site_config.jsondirectly - ✅ Can grant full access by setting
licensed_modulesto["all"]or[]or["Accounting",...]
Available Modules
- Accounts
- Selling
- Buying
- Stock
- Manufacturing
- Projects
- CRM
- Support
- Assets
- Maintenance
- Quality Management
- Subcontracting
- Setup (always included)
Common Tasks
Grant Full Access to a Site
bench --site [site_name] execute erpnext_module_gate.erpnext_module_gate.set_all_modules.set_all
Change Licensed Modules
# Via bench console
bench --site [site_name] console
# Then in console:
from erpnext_module_gate.erpnext_module_gate.api import set_licensed_modules
set_licensed_modules(["Accounts", "Selling", "Stock"])
Check Current Licensed Modules
from erpnext_module_gate.erpnext_module_gate.api import get_licensed_modules
print(get_licensed_modules())
Troubleshooting
Users can access all modules
Check: Verify licensed_modules is set in site_config.json:
import frappe
print(frappe.conf.get("licensed_modules"))
Fix: Set modules using the methods above.
System Manager can still access unlicensed modules
Check: Verify the app is installed and hooks are loaded:
bench restart
bench --site [site_name] clear-cache
Administrator cannot access modules
Note: Administrator should always have full access. If not, check:
from erpnext_module_gate.erpnext_module_gate.api import is_administrator
print(is_administrator("Administrator")) # Should be True
Integration with SaaS
The app automatically integrates with ERPNext SaaS registration workflows:
- User selects modules during registration
- Modules are stored in
site_config.json - Permissions are enforced on first login
- Workspaces are automatically filtered
Security
- Multi-layer protection - Three security layers prevent bypass attempts
- System Manager restrictions - Even System Managers cannot access unlicensed ERPNext modules
- Custom module support - All custom modules (non-ERPNext) are accessible by default
- Administrator bypass - Only Administrator account has full access
- Real-time enforcement - Restrictions are checked on every access attempt
Important Notes
Custom Modules
All custom modules outside ERPNext are accessible by default, regardless of licensing configuration. This includes:
- Modules from custom apps (e.g., custom_app)
- Modules that don't belong to the erpnext app
- Only ERPNext modules are restricted based on licensed_modules configuration
This means you don't need to add custom modules to the licensed modules list - they work automatically!
Support
For detailed technical documentation, see TECHNICAL.md
For implementation status and testing guides, see:
- IMPLEMENTATION_STATUS.md
- TESTING_GUIDE.md
- SECURITY_PROTECTIONS.md
License
MIT
Related Other apps for Frappe & ERPNext
- Erpnext — Free and Open Source Enterprise Resource Planning (ERP)
- Helpdesk — Modern, Streamlined, Free and Open Source Customer Service Software
- Print Designer — Visual print designer for Frappe / ERPNext
- Ctr — CTR模型代码和学习笔记总结
- Whitelabel — Whitelabel ERPNext
- Fossunited — fossunited.org
- Helm — Helm Chart Repository for Frappe/ERPNext
- Frappe Attachments S3 — A frappe app to upload file attachments in doctypes to s3.