Claude-skill-registry create-odoo-pwa
Generate an offline-first Progressive Web App with Odoo Studio backend integration. Use when user wants to create new Odoo-backed application, mentions "PWA with Odoo", "offline Odoo app", "Odoo Studio PWA", or similar terms. Supports SvelteKit, React, and Vue frameworks.
git clone https://github.com/majiayu000/claude-skill-registry
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/create-odoo-pwa" ~/.claude/skills/majiayu000-claude-skill-registry-create-odoo-pwa && rm -rf "$T"
skills/data/create-odoo-pwa/SKILL.mdCreate Odoo PWA Application
Generate a production-ready Progressive Web App with Odoo Studio backend, featuring offline-first architecture, smart caching, and automatic synchronization.
Before You Start
This skill generates a complete PWA project following proven architectural patterns:
- Three-layer data flow: Component → Cache Store → API Client → Server Route → Odoo
- Offline-first: IndexedDB/localStorage with background sync
- Smart caching: Incremental fetch, stale detection, optimistic updates
- PWA-ready: Service workers, manifest, installable
Required User Input
Ask the user for the following information before generating:
-
Project name (required)
- Format: kebab-case (e.g., "inventory-tracker", "expense-manager")
- Used for directory name and package.json
-
Framework (required)
- Options:
(recommended),sveltekit
,reactvue - Default: sveltekit if not specified
- Options:
-
Primary Odoo model (required)
- The main custom model name WITHOUT the
prefixx_ - Example: If Odoo model is
, user provides:x_inventoryinventory - Will automatically add
prefix in codex_
- The main custom model name WITHOUT the
-
Model display name (required)
- Human-readable singular name (e.g., "Inventory Item", "Expense")
-
Deployment target (optional)
- Options:
,vercel
,github-pages
,cloudflarenetlify - Default: vercel if not specified
- Options:
Generation Steps
Step 1: Project Initialization
Create the project directory and initialize the structure:
mkdir {{PROJECT_NAME}} cd {{PROJECT_NAME}}
Generate the appropriate structure based on framework:
- SvelteKit: Use SvelteKit 2.x structure with
directorysrc/ - React: Use Vite + React structure
- Vue: Use Vite + Vue structure
Step 2: Base Configuration Files
Generate these files using templates from
skills/create-odoo-pwa/templates/{{FRAMEWORK}}/base/:
For SvelteKit:
- Dependencies including @sveltejs/kit, @vite-pwa/sveltekit, @sveltejs/adapter-staticpackage.json
- SvelteKit configuration with adapter-staticsvelte.config.js
- Vite + PWA plugin configurationvite.config.js
orjsconfig.json
- Path aliases and compiler optionstsconfig.json
For React:
- Dependencies including React 18, Vite, vite-plugin-pwapackage.json
- React + PWA plugin configurationvite.config.js
- TypeScript configurationtsconfig.json
For Vue:
- Dependencies including Vue 3, Vite, vite-plugin-pwapackage.json
- Vue + PWA plugin configurationvite.config.js
- TypeScript configurationtsconfig.json
Step 3: Environment and Git Configuration
Create
.env.example:
# Odoo Instance Configuration ODOO_URL=https://your-instance.odoo.com ODOO_DB=your-database-name ODOO_USERNAME=your-username ODOO_API_KEY=your-api-key # Primary Model (use x_ prefix) ODOO_PRIMARY_MODEL=x_{{MODEL_NAME}} # Optional: For static hosting (GitHub Pages, etc.) PUBLIC_API_URL=
Create
.gitignore:
node_modules/ .env dist/ build/ .svelte-kit/ .vercel/ .DS_Store *.log
Step 4: Core Library Files
Generate these essential files from templates:
A. Odoo API Client (src/lib/odoo.js
)
src/lib/odoo.jsFeatures:
- API URL configuration (supports PUBLIC_API_URL for static hosts)
- Core API communicationcallApi(action, data)
- Create recordscreateRecord(model, fields)
- Search/read recordssearchRecords(model, domain, fields)
- Update recordsupdateRecord(model, id, values)
- Delete recordsdeleteRecord(model, id)
- Format single relation fieldsformatMany2one(id)
- Format multi-relation fieldsformatMany2many(ids)- Model-specific convenience methods
B. IndexedDB Manager (src/lib/db.js
)
src/lib/db.jsFeatures:
- Database initialization with versioning
- Store definitions for master data (partners, categories, config)
- CRUD operations:
,add()
,get()
,getAll()
,update()remove() - Transaction helpers
- Error handling
C. Smart Cache Store (src/lib/stores/{{MODEL_NAME}}Cache.js
)
src/lib/stores/{{MODEL_NAME}}Cache.jsFeatures:
- Framework-specific store pattern (Svelte store/React context/Vue composable)
- Dual storage strategy (localStorage for metadata, IndexedDB for master data)
- Load cache and start background syncinitialize()
- Incremental sync with Odoosync(forceFullRefresh)
- Clear cache and full syncforceRefresh()- Partner name resolution with caching
- Optimistic UI updates
- Stale detection (5-minute cache validity)
- Background sync (3-minute intervals)
- Derived stores for UI states
D. Utility Functions (src/lib/{{MODEL_NAME}}Utils.js
)
src/lib/{{MODEL_NAME}}Utils.jsFeatures:
- Business logic calculations
- Data normalization helpers
- Field formatters
Step 5: Server-Side API Proxy
For SvelteKit: src/routes/api/odoo/+server.js
src/routes/api/odoo/+server.jsFeatures:
- JSON-RPC client for Odoo
- UID caching to reduce auth calls
helperexecute(model, method, args, kwargs)- POST request handler with actions:
- Create new recordcreate
- Search and read recordssearch
- Search any Odoo modelsearch_model
- Update existing recordupdate
- Delete recorddelete
- Error handling with descriptive messages
- Environment variable access
For React/Vue: src/api/odoo.js
(server endpoint)
src/api/odoo.jsSimilar functionality adapted to framework conventions
Step 6: UI Components and Routes
Generate starter components and pages:
SvelteKit Routes:
- Root layout with navigationsrc/routes/+layout.svelte
- SSR/CSR configuration (ssr: false, csr: true)src/routes/+layout.js
- Main form for creating recordssrc/routes/+page.svelte
- List/table view with filteringsrc/routes/list/+page.svelte
- HTML template with PWA meta tagssrc/app.html
React/Vue Pages:
Equivalent component structure adapted to framework conventions
Shared Components:
- Shows online/offline statusOfflineBanner
- Displays sync state and last sync timeSyncStatus
- Loading indicatorLoadingSpinner- Form components with offline support
Step 7: PWA Configuration
Generate PWA files:
static/manifest.json
(or public/manifest.json
):
static/manifest.jsonpublic/manifest.json{ "name": "{{PROJECT_NAME}}", "short_name": "{{PROJECT_NAME}}", "description": "{{MODEL_DISPLAY_NAME}} management app", "start_url": "/", "display": "standalone", "background_color": "#ffffff", "theme_color": "#667eea", "icons": [ { "src": "/icon-192.png", "sizes": "192x192", "type": "image/png" }, { "src": "/icon-512.png", "sizes": "512x512", "type": "image/png" } ] }
Configure service worker in
vite.config.js:
- Auto-update strategy
- Cache all static assets
- Offline support
Step 8: Deployment Configuration
Generate deployment files based on target:
Vercel (vercel.json
):
vercel.json{ "buildCommand": "npm run build", "outputDirectory": "build", "framework": "sveltekit", "regions": ["iad1"] }
GitHub Pages (.github/workflows/deploy.yml
):
.github/workflows/deploy.ymlname: Deploy to GitHub Pages on: push: branches: [main] jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 - run: npm ci - run: npm run build - uses: actions/upload-pages-artifact@v2 with: path: build
Cloudflare/Netlify:
Generate appropriate configuration files
Step 9: Documentation
Generate comprehensive documentation:
README.md
:
README.md- Project overview
- Prerequisites (Node.js, Odoo account)
- Installation steps
- Odoo Studio model setup instructions
- Development commands
- Deployment guide
- Architecture overview
CLAUDE.md
:
CLAUDE.mdComplete architecture documentation following the expense-split-pwa pattern:
- Project overview
- Development commands
- Environment setup
- Architecture diagrams
- Key architectural patterns
- Odoo model structure
- Important development notes
- Common gotchas
API.md
:
API.md- Odoo integration patterns
- Available API methods
- Field formatting examples
- Common operations
Step 10: Post-Generation Instructions
After generating all files, provide the user with:
✅ Project '{{PROJECT_NAME}}' generated successfully! 📋 Next Steps: 1. Navigate to the project: cd {{PROJECT_NAME}} 2. Install dependencies: npm install 3. Configure Odoo credentials: cp .env.example .env # Edit .env with your Odoo instance details 4. Create Odoo Studio Model: - Log into your Odoo instance - Go to Studio - Create a new model named: x_{{MODEL_NAME}} - Add custom fields with x_studio_ prefix - Example fields: * x_name (Char) - Required * x_studio_description (Text) * x_studio_value (Float) * x_studio_date (Date) * x_studio_category (Many2one → res.partner or custom) 5. Start development server: npm run dev 6. Generate PWA icons: - Create 192x192 and 512x512 PNG icons - Place in static/ or public/ directory - Name them icon-192.png and icon-512.png 7. Deploy (optional): - Vercel: vercel - GitHub Pages: Push to main branch - Cloudflare: wrangler deploy - Netlify: netlify deploy 📚 Documentation: - README.md - Getting started guide - CLAUDE.md - Architecture documentation - API.md - Odoo integration patterns 🔗 Resources: - Odoo API Docs: https://www.odoo.com/documentation/ - SvelteKit Docs: https://kit.svelte.dev/
Template Variables
When generating files, replace these placeholders:
- User's project name (kebab-case){{PROJECT_NAME}}
- Odoo model name without x_ prefix{{MODEL_NAME}}
- Human-readable model name{{MODEL_DISPLAY_NAME}}
- sveltekit/react/vue{{FRAMEWORK}}
- vercel/github-pages/cloudflare/netlify{{DEPLOYMENT_TARGET}}
- User's name (if provided){{AUTHOR_NAME}}
Common Patterns from expense-split-pwa
This skill implements proven patterns from the expense-split-pwa project:
- Smart Caching: Load from cache immediately, sync in background if stale
- Incremental Fetch: Only fetch records with
id > lastRecordId - Partner Resolution: Batch-fetch and cache partner names
- Dual-Phase Calculation: Process settled/unsettled records separately
- Optimistic Updates: Update UI immediately, sync to server in background
- Error Recovery: Graceful degradation when offline
Error Handling
If generation fails:
- Verify all required input is provided
- Check template files exist
- Ensure proper permissions for file creation
- Provide clear error messages to user
Framework-Specific Notes
SvelteKit
- Use Svelte 5 runes syntax (
,$state
,$derived
)$effect - Configure adapter-static for static deployment
- Set
for client-side only appsssr: false - Use
for base path support$app/paths
React
- Use React 18+ with hooks
- Context API for global state
- React Query for server state (optional)
- Vite for build tooling
Vue
- Use Vue 3 Composition API
- Pinia for state management
- Composables for reusable logic
- Vite for build tooling
Testing the Generated Project
After generation, verify:
completes without errorsnpm install
starts development servernpm run dev- Form renders correctly
- Offline banner appears when disconnecting
- Data persists in localStorage/IndexedDB
- Sync works when back online
Support
For issues or questions:
- Check CLAUDE.md for architecture details
- Review generated code comments
- Consult Odoo API documentation
- Verify environment variables are set correctly