这个功能为 ERPNext 应用添加了一个测试页面,展示如何:
uperp/uperp/api.py - 后端 API 接口uperp/templates/pages/test.py - 页面上下文处理uperp/config/desktop.py - 桌面菜单配置uperp/config/uperp.py - 模块菜单配置uperp/hooks.py - 应用钩子配置uperp/templates/pages/test.html - 页面HTML模板uperp/public/js/test-page.js - 页面JavaScript逻辑uperp/public/css/test-page.css - 页面样式get_test_data() - 获取测试数据列表get_dashboard_stats() - 获取仪表板统计数据test_api_connection() - 测试 API 连接has_app_permission() - 权限检查http://your-erpnext-site/test
cd /path/to/your/bench
bench get-app /path/to/uperp
bench install-app uperp
bench restart
bench clear-cache
bench clear-website-cache
在 uperp/uperp/api.py 中的 get_test_data() 函数可以修改数据源:
# 从数据库获取真实数据
test_data = frappe.get_all("YourDocType",
fields=["name", "description", "status"],
limit=10)
在 api.py 文件中添加新的函数并使用 @frappe.whitelist() 装饰器:
@frappe.whitelist()
def your_new_api():
# 你的逻辑
return {"success": True, "data": "your_data"}
编辑 uperp/public/css/test-page.css 文件来调整页面样式。
在 uperp/public/js/test-page.js 中添加新的JavaScript函数。
@frappe.whitelist() 装饰器