Yes, you can implement a Single Page Application (SPA)-like experience in ERPNext's Home Workspace similar to Gmail — where the left sidebar shows modules and their DocTypes, and clicking on them loads content dynamically into the right pane without full page reloads.
This is absolutely possible using Frappe’s modern UI components and APIs. Let me walk you through how to do it step-by-step, including:
✅ Goal Recap
You want:
- Left Sidebar: ERPNext Modules with expandable/collapsible list of DocTypes under each module.
- Right Pane: SPA-style dynamic loading of relevant DocType lists, reports, or dashboards.
- No full page reloads when navigating between items.
🧰 Technologies Involved
- Frappe Framework (Python + JS)
- Workspace Builder (v14+)
- frappe.router / frappe.views
- React (optional for advanced UI)
- Custom Desk Pages (via
Page DocType)
- Client Scripting (
frappe.ui.form.on, frappe.call)
- Frappe UI Components (Dialog, List, Form, etc.)
🔨 Step-by-Step Implementation Plan
1. Enable Module-Based Navigation via Custom Workspace
ERPNext v14+ has a built-in Workspace Builder that allows creating custom workspaces with cards, links, and sections.
Steps:
- Go to Home > Workspaces > [Your Workspace].
- Use the Builder Mode to:
- Add Sections for each ERPNext module (e.g., Sales, Accounts, HR).
- Under each section, add Links to DocTypes (e.g., Customer, Quotation, Invoice).
This gives you a modular layout but still triggers page reloads.
2. Override Default Behavior with SPA Logic
To avoid page reloads, we need to intercept clicks on these links and load the content dynamically.
Create a Custom App or Customize Existing One
bench new-app erpnext_spa
cd erpnext_spa
Register Your App in Hooks
In erpnext_spa/hooks.py:
from __future__ import unicode_literals
app_name = "erpnext_spa"
app_title = "ERPNext SPA"
app_publisher = "Your Name"
app_description = "SPA-style workspace for ERPNext"
app_icon = "octicon octicon-file-directory"
app_color = "blue"
app_email = "you@example.com"
app_license = "MIT"
# Includes in <head>
app_include_css = "/assets/erpnext_spa/css/erpnext_spa.css"
app_include_js = "/assets/erpnext_spa/js/erpnext_spa.js"
3. Create a Custom Desk Page (SPA Layout)
Create a file:
erpnext_spa/erpnext_spa/page/spa_workspace/spa_workspace.py
from __future__ import unicode_literals
import frappe
def get_context(context):
context.no_cache = 1
return context
And the HTML template:
erpnext_spa/erpnext_spa/page/spa_workspace/spa_workspace.html
{% extends "templates/web.html" %}
{% block page_content %}
<div class="spa-container">
<div class="sidebar">
<h3>Modules</h3>
<ul id="module-list"></ul>
</div>
<div class="main-content" id="workspace-main">
<div class="default-message">
Select a module from the left to view its DocTypes.
</div>
</div>
</div>
{% endblock %}
{% block script %}
<script type="text/javascript">
// Load modules and bind click events
$(document).ready(function () {
frappe.call({
method: "erpnext_spa.spa_workspace.get_modules_with_doctypes",
callback: function (r) {
if (r.message) {
const modules = r.message;
const $list = $("#module-list");
modules.forEach(module => {
const $li = $("<li>").append(`<strong>${module.module}</strong>`);
const $subList = $("<ul>");
module.doctypes.forEach(dt => {
$subList.append(
`<li><a href="#" data-doctype="${dt}">${dt}</a></li>`
);
});
$li.append($subList);
$list.append($li);
});
// Handle click on DocType link
$("#module-list a").on("click", function (e) {
e.preventDefault();
const doctype = $(this).attr("data-doctype");
load_list_view(doctype);
});
}
},
});
});
function load_list_view(doctype) {
frappe.views.get_list_view(doctype, "#workspace-main");
}
</script>
{% endblock %}
4. Backend API to Fetch Modules & DocTypes
Add this method to your app:
erpnext_spa/erpnext_spa/space_workspace.py
# server-side method
def get_modules_with_doctypes():
# Get all standard ERPNext modules
modules = frappe.get_all("Module Def", fields=["name"])
result = []
for m in modules:
# Get all DocTypes linked to this module
dt_list = frappe.get_all("DocType", filters={"module": m.name}, fields=["name"])
if dt_list:
result.append({
"module": m.name,
"doctypes": [d.name for d in dt_list]
})
return result
Register the method in hooks:
doc_events = {}
scheduler_events = {}
override_whitelisted_methods = {
"erpnext_spa.spa_workspace.get_modules_with_doctypes": "erpnext_spa.spa_workspace.get_modules_with_doctypes"
}
5. Add CSS for Layout
erpnext_spa/public/css/erpnext_spa.css
.spa-container {
display: flex;
height: 100vh;
}
.sidebar {
width: 250px;
padding: 1rem;
background-color: #f8f9fa;
border-right: 1px solid #ccc;
}
.main-content {
flex: 1;
padding: 1rem;
overflow-y: auto;
}
6. Test It Out
- Install the app:
bench install-app erpnext_spa
-
Visit:
/app/spa-workspace
-
You’ll see:
- A static left sidebar with modules and DocTypes.
- Clicking a DocType will load its list view in-place, without reloading the page.
✅ Optional Enhancements
| Feature | How to Do It |
|---|
| Search Bar | Add input field and use frappe.search() or custom query |
| Custom Dashboards | Replace load_list_view with frappe.set_route('query-report', 'Your Report') |
| Dynamic Tabs per Module | Use frappe.ui.TabBar or Bootstrap tabs |
| React Integration | Build a React component and mount it inside #workspace-main |
| Dark Mode Toggle | Use local storage and toggle a .dark class |
🚀 Final Tips
- Use
frappe.views.get_list_view() for fast, native list rendering.
- For more control, build a custom
ListView or FormView.
- Cache frequently accessed DocTypes/modules to improve performance.
- Consider bundling this as a reusable plugin or theme for ERPNext.
Want Me to Package This?
If you'd like, I can help you package this entire solution as a ready-to-install custom Frappe app with proper structure, tests, and documentation.
Just say the word 👇
Let me know what kind of customization you're aiming for — I'm happy to tailor the solution further!