Development Environment Setup¶
This guide covers setting up a local development environment for contributing to AgriOS.
Prerequisites¶
Ensure you have installed:
Git
Docker and Docker Compose (recommended)
Python 3.10+ (for native development)
A code editor (VS Code, PyCharm, etc.)
Quick Setup with Docker¶
Docker provides the fastest path to a working development environment.
1. Clone the Repository¶
git clone https://github.com/advanceinsight/AgriOS.git
cd AgriOS
2. Start the Development Environment¶
# Copy environment template
cp .env.example .env
# Start services
docker compose up -d
3. Access AgriOS¶
Open http://localhost:8069 in your browser.
Default credentials (development only):
Database: Create a new one via the database manager
Admin email: Set during database creation
4. Development Workflow¶
# View logs
docker compose logs -f
# Restart after Python changes
docker compose restart odoo
# Update module after XML changes
docker compose exec odoo odoo -u your_module -d your_database --stop-after-init
Native Development Setup¶
For more control, set up a native development environment.
1. Install System Dependencies¶
Ubuntu/Debian:
sudo apt update
sudo apt install -y python3-pip python3-dev python3-venv \
libxml2-dev libxslt1-dev zlib1g-dev libsasl2-dev \
libldap2-dev build-essential libssl-dev libffi-dev \
libjpeg-dev libpq-dev liblcms2-dev libblas-dev \
libatlas-base-dev wkhtmltopdf nodejs npm git
macOS:
brew install python@3.10 postgresql node wkhtmltopdf
2. Install PostgreSQL¶
# Ubuntu
sudo apt install postgresql postgresql-client
sudo -u postgres createuser -s $USER
# macOS
brew install postgresql
brew services start postgresql
3. Clone Repositories¶
# Create development directory
mkdir -p ~/odoo-dev
cd ~/odoo-dev
# Clone Odoo
git clone https://github.com/odoo/odoo.git --depth 1 --branch 18.0
# Clone AgriOS
git clone https://github.com/advanceinsight/AgriOS.git
4. Set Up Python Environment¶
# Create virtual environment
python3 -m venv venv
source venv/bin/activate
# Install Odoo dependencies
pip install -r odoo/requirements.txt
# Install AgriOS dependencies (if any)
pip install -r AgriOS/requirements.txt
5. Configure Odoo¶
Create odoo.conf:
[options]
addons_path = ~/odoo-dev/odoo/addons,~/odoo-dev/AgriOS
db_host = localhost
db_port = 5432
db_user = your_username
db_password = false
admin_passwd = admin
dev_mode = reload,qweb,xml
6. Run Odoo¶
# Activate virtual environment
source ~/odoo-dev/venv/bin/activate
# Start Odoo
./odoo/odoo-bin -c odoo.conf
IDE Configuration¶
VS Code¶
Recommended extensions:
Python (Microsoft)
Pylance
XML Tools
Docker
Workspace settings (.vscode/settings.json):
{
"python.defaultInterpreterPath": "~/odoo-dev/venv/bin/python",
"python.analysis.extraPaths": [
"~/odoo-dev/odoo",
"~/odoo-dev/AgriOS"
]
}
PyCharm¶
Open the AgriOS directory as a project
Configure Python interpreter to use your virtual environment
Add Odoo source to project structure
Configure run configuration with
odoo-bin
Running Tests¶
Run tests for a specific module:
# Docker
docker compose exec odoo odoo -i agrios_farmer --test-enable -d test_db --stop-after-init
# Native
./odoo-bin -i agrios_farmer --test-enable -d test_db --stop-after-init
Run specific test class:
./odoo-bin -i agrios_farmer --test-tags agrios_farmer -d test_db --stop-after-init
Debugging¶
Using pdb¶
Add breakpoints in your code:
import pdb; pdb.set_trace()
Then run Odoo without -d flag to enable interactive debugging.
Using VS Code Debugger¶
Create .vscode/launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Odoo",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/../odoo/odoo-bin",
"args": ["-c", "odoo.conf"],
"cwd": "${workspaceFolder}"
}
]
}
Useful Commands¶
# Create new database
./odoo-bin -d new_database -i base --stop-after-init
# Update specific module
./odoo-bin -u agrios_farmer -d your_database --stop-after-init
# Update all AgriOS modules
./odoo-bin -u agrios_farmer,agrios_plot,agrios_trade,agrios_training -d your_database --stop-after-init
# Scaffold new module
./odoo-bin scaffold agrios_newmodule ~/odoo-dev/AgriOS
Troubleshooting¶
Module not found after changes
Run “Update Apps List” in Odoo
Check
addons_pathin configurationRestart Odoo server
Database connection errors
Verify PostgreSQL is running
Check database user exists
Confirm connection settings in
odoo.conf
Asset compilation errors
Clear browser cache
Run:
./odoo-bin -u agrios_theme -d your_database
Need more help? See Developer FAQ or open an issue on GitHub.