Custom Inventory Frontend For ERPNext
You can install this app using the bench CLI:
cd $PATH_TO_YOUR_BENCH
bench get-app $URL_OF_THIS_REPO --branch main
bench install-app temple_inventoryValidation commands (Ruff, Prettier, type-check, tests) are listed in AGENTS.md; CI runs the same checks on every push.
mit
For a disposable development site only, rebuild the complete site database, run
the ERPNext setup (company Org, site time zone America/New_York, batch tracking
on), remove ERPNext's default warehouses and records, and load the Temple Inventory
samples (temple_inventory/native_samples.py).
./apps/temple_inventory/scripts/reset-development-samples --site development.localhost--data chooses what is seeded:
| Mode | Contents |
|---|---|
full (default) |
The real costume catalog with images, opening stock in 第2寺院 (T2) / A02, plus generated test volume: general catalog items, batches, locations in 第1寺院, 第2寺院, 东山寺区 (with subdivided shelves and a disabled room) and 活动现场, a workflow of receipts, issues, transfers, loans, returns, damage, counts and activities, and a large generated record history. Use it for UI, performance and acceptance work |
real |
Only the real costume catalog, its images and its opening stock in 第2寺院 / A02, with the 第1寺院 and 第2寺院 rooms. Use it to see the launch data alone |
After seeding, the script runs sample_install.verify_development_sample, which
checks the warehouse contract, stocked leaves and image coverage.
The command requires the MariaDB root password and an exact RESET <site>
confirmation. It accepts only development.localhost (or a site whose config sets
temple_inventory_sample_site=1, such as CI and the public sample site) and refuses
a site without developer_mode=1 unless you pass --allow-non-developer together
with --yes-i-understand-this-is-destructive. The existing Administrator password
is preserved. Run --help for company, currency and fiscal-year options.
Seeding takes several minutes, so the reset saves the seeded site (database and
files) under development/.sample-snapshots/ and restores it on later resets
instead of seeding again; the three newest snapshots are kept.
scripts/sample-snapshot keys a snapshot by the app's
backend source (tests excluded), the Frappe and ERPNext commits and the seed
arguments. A snapshot is used only on the day, in the site's time zone, it was
seeded, because sample dates are relative to that day. Pass --no-snapshot to
seed from scratch. CI caches the same snapshot between runs.
In the development stack, MariaDB runs on host mariadb with root user root and
password 123, set by MYSQL_ROOT_PASSWORD in dev/compose.yaml.
This is a local development credential only; it is unrelated to the site's
Administrator password (admin). A non-interactive reset, from the bench root on
the WSL host:
echo "RESET development.localhost" | apps/temple_inventory/scripts/dx env MARIADB_ROOT_PASSWORD=123 \
./apps/temple_inventory/scripts/reset-development-samples --site development.localhostIf the compose file changes the password, that file is the source of truth.
It permanently removes all database records, does not create a backup, and must
never be used on a production site. Progress, server errors, and tracebacks are
shown directly in the terminal and written to logs/temple-sample-reset-*.log.
The script accepts only development.localhost. The public sample site is created
once by deploy/stack/bootstrap.sh; see
deploy/README.md.
Every full sample seed creates these accounts, so https://sample.kufang.online/inventory
has them after each deployment. So does development.localhost after a sample reset.
All of them, and Administrator, sign in with the password admin. These are public
demo logins; production disables every *@example.com account.
| Account | Role in the app | Native role | For testing |
|---|---|---|---|
viewer@example.com |
只读 | Inventory Viewer | Read-only pages and exports |
operator@example.com |
录入员 | Inventory Operator | Daily stock work and Items |
manager@example.com |
负责人 | Inventory Manager | 盘点, cancel and amend, catalog data |
inventory.admin@example.com |
管理员 | Inventory Administrator + System Manager | Warehouses, settings, Desk users |
noaccess@example.com |
none | Stock User | The no-access page |
Administrator |
管理员 | built-in | Recovery account; always admitted |
chen.ming, lin.hui, wang.jianguo, zhao.ya and zhou.ping (all @example.com) are
Inventory Managers who appear as the actors in sample history. Use inventory.admin@example.com,
not admin@example.com, which Frappe reserves for the built-in Administrator.
What each role can do:
| Action | 只读 | 录入员 | 负责人 | 管理员 |
|---|---|---|---|---|
| Browse, search, report, export and print | ✅ | ✅ | ✅ | ✅ |
| Create, edit and disable Items; edit Batches | — | ✅ | ✅ | ✅ |
| Create and edit Activities | — | ✅ | ✅ | ✅ |
| Create, save and submit every movement kind | — | ✅ | ✅ | ✅ |
| Add attachments; remove them from drafts and Items | — | ✅ | ✅ | ✅ |
| Remove attachments from submitted records | — | — | ✅ | ✅ |
| Create, edit and submit 盘点调整 and 期初库存 | read only | read only | ✅ | ✅ |
| Cancel and amend records; delete drafts | — | — | ✅ | ✅ |
| Import Items and Opening Stock | — | — | ✅ | ✅ |
| Manage 类别, 单位 and 活动类型 | read only | read only | ✅ | ✅ |
| Delete Items and Activities | — | — | — | ✅ |
| Configure Warehouses and settings | read only | read only | read only | ✅ |
| Manage users and roles in ERPNext Desk | — | — | — | ✅ |
An 录入员 cannot delete an autosaved draft; only unsaved input can be discarded. See docs/imports.zh-CN.md for imports and docs/rollout-progress.md for rollout status.
To give a real user a role, open the User in ERPNext Desk and set one Role Profile: 物资只读, 物资录入员, 物资负责人 or 物资管理员. Company, warehouse root and User Permission limits apply on top of the role.
Agents and Git run on the WSL2 host; Bench, MariaDB and Redis run in Docker. See
AGENTS.md ("Development environment") for the scripts/dx wrapper and compose
commands, and deploy/README.md for the sample deployment that
every push to main triggers.
The development site may set temple_inventory_environment in its site config
to development, sample, staging or production for runtime branding. If
the key is missing, developer_mode selects development; otherwise the safe
default is production. An unset System Settings timezone is set to
America/New_York during migrate.
Run these from this app's directory in a WSL terminal (VS Code opened on the WSL folder, not "Reopen in Container").
-
Start the stack. Start, restart and inspect services using the Development environment commands in AGENTS.md. The web service serves the built frontend on port 8000.
-
Frontend with hot reload (optional). Port 8000 serves the last
pnpm build. For live editing, run the Vite dev server in the container. It serves on port 8080 and passes API calls through to port 8000. Stop it with Ctrl+C:cd frontend ../scripts/dx pnpm dev --host 0.0.0.0To see frontend changes on port 8000 instead, rebuild with
../scripts/dx ../scripts/heavy pnpm build. -
Open it. Log in as
Administrator/admin.What URL Inventory app, built (port 8000) http://localhost:8000/inventory Inventory app, Vite hot reload (port 8080) http://localhost:8080/inventory/ ERPNext Desk http://localhost:8000/desk localhost:8000serves the default site,development.localhost.http://development.localhost:8000also works in Chrome and Edge.
The ports are published on WSL's 127.0.0.1, and WSL's localhost forwarding
(localhostForwarding=true in C:\Users\<you>\.wslconfig, the default) makes
them reachable as http://localhost:8000 and http://localhost:8080 from a Windows
browser, which counts as a secure context for PWA install, the service worker and
the camera scanner. Mirrored networking (networkingMode=mirrored) also works but
is not required.
If one port works and another does not, something on Windows is already holding that port, and WSL cannot forward it. Check in PowerShell:
Get-NetTCPConnection -LocalPort 8000 -State Listen | Select LocalAddress,OwningProcess
netsh interface portproxy show allOn this PC an old netsh interface portproxy rule (0.0.0.0:8000 to
127.0.0.1:8000, owned by the IP Helper service) held port 8000. Remove such a
rule from an Administrator PowerShell:
netsh interface portproxy delete v4tov4 listenport=8000 listenaddress=0.0.0.0WSL does not retry a port it could not forward, so after removing the conflict
run docker compose -f dev/compose.yaml up -d --force-recreate frappe web worker
to publish the port again.
If forwarding stops working altogether, wsl --shutdown (which also stops the
Docker stack and any agent running in WSL) and reopen the WSL terminal.
Fallback: the WSL IP address. Publish the ports on every WSL interface, then browse to WSL's IP:
TI_DEV_BIND=0.0.0.0 docker compose -f dev/compose.yaml up -d
hostname -I | awk '{print $1}' # changes after each WSL restartA plain-HTTP IP address is not a secure context, so PWA install, the service worker
and the camera scanner do not work there. Run docker compose -f dev/compose.yaml up -d without the variable to go back to loopback-only.
To test PWA install against a real HTTPS site without any of this, use the sample deployment at https://sample.kufang.online/inventory.