2.9 KiB
2.9 KiB
Interactive setup wizard for configuring Odoo PWA environment variables.
What this command does:
- Guides the user through setting up their
.envfile - Validates Odoo connection credentials
- Tests API connectivity
- Configures model-specific settings
- Provides troubleshooting help if connection fails
Required Information:
Gather from the user:
- Odoo Instance URL (e.g., "https://yourcompany.odoo.com")
- Database Name (e.g., "yourcompany-main")
- API Key (from Odoo user preferences)
- Username/Email (Odoo user email)
- Primary Model Name (e.g., "x_expense", "x_inventory")
Steps:
- Check if
.env.exampleexists in the current directory - If not, ask if this is an Odoo PWA project
- Ask the user for each environment variable interactively
- Validate URL format (must start with http:// or https://)
- Create or update
.envfile with the provided values - Test the connection by making a simple API call to Odoo
- If connection fails, provide troubleshooting steps
- Display success message with next steps
Environment Variables to Set:
# Odoo Instance Configuration
VITE_ODOO_URL=https://yourcompany.odoo.com
VITE_ODOO_DB=yourcompany-main
# Authentication (keep these secret!)
ODOO_API_KEY=your_api_key_here
ODOO_USERNAME=your.email@company.com
# Model Configuration
VITE_MODEL_NAME=x_expense
VITE_MODEL_DISPLAY_NAME=Expense
Validation Tests:
After creating .env, run these checks:
- Test Odoo URL is reachable
- Verify API key is valid
- Check if the model exists in Odoo
- Test read permissions on the model
- Verify required fields are accessible
Example prompts to use this command:
/setup-env- Interactive setup wizard- User: "Help me configure my Odoo credentials"
- User: "Set up environment variables for Odoo PWA"
Security Reminders:
After setup, remind the user:
- ✅
.envshould be in.gitignore(verify this) - ✅ Never commit API keys to version control
- ✅ Use different credentials for development and production
- ✅ For deployment, set environment variables in the hosting platform
- ✅ Rotate API keys periodically
Troubleshooting Common Issues:
Connection Failed
- Verify Odoo URL is correct and accessible
- Check if API key is valid (generate new one in Odoo)
- Ensure username matches the API key owner
- Check firewall/network restrictions
Model Not Found
- Verify the model exists in Odoo Studio
- Check model name has
x_prefix - Ensure user has access permissions to the model
Authentication Error
- Regenerate API key in Odoo (Settings → Users → API Keys)
- Verify database name is correct
- Check if account is active and not locked
After Setup:
Remind the user to:
- Restart the development server to load new environment variables
- Test the application and verify data loads correctly
- Keep the
.env.examplefile updated for team members - Document any custom configuration in project README