Developer FAQ¶
Frequently asked questions for AgriOS developers.
General Development¶
What version of Odoo does AgriOS support?¶
AgriOS 1.0.0 requires Odoo 18 Community Edition.
How do I set up a development environment?¶
See the Development Setup guide for setting up a local development environment, or Self-Hosted Installation for production deployment.
Where can I find the source code?¶
The AgriOS source code is available on GitHub: https://github.com/advanceinsight/AgriOS
Module Development¶
How should I structure a new AgriOS module?¶
Follow the standard Odoo module structure and the AgriOS naming conventions:
agrios_mymodule/
├── __init__.py
├── __manifest__.py
├── models/
│ ├── __init__.py
│ └── my_model.py
├── views/
│ └── my_model_views.xml
├── security/
│ ├── ir.model.access.csv
│ └── security.xml
├── data/
│ └── data.xml
└── static/
└── description/
└── icon.png
How do I extend an existing AgriOS model?¶
Use Odoo’s inheritance mechanism:
from odoo import models, fields
class FarmerExtension(models.Model):
_inherit = 'farmer.group'
custom_field = fields.Char(string='Custom Field')
What naming convention should I use for models?¶
Use lowercase with dots for model names:
farmer.interactionUse descriptive names that indicate the domain:
agrios.areaSee AgriOS Naming Conventions for details
Database and Data¶
How do I run database migrations?¶
Odoo handles migrations automatically when you update modules. To update a specific module:
# Docker
docker compose exec odoo odoo -u agrios_farmer -d your_database --stop-after-init
# Native
./odoo-bin -u agrios_farmer -d your_database --stop-after-init
How do I import test/demo data?¶
Demo data files are in each module’s demo/ directory. Enable demo data when creating a new database, or load it manually:
./odoo-bin -i agrios_demo -d your_database
How do I back up and restore the database?¶
# Backup
pg_dump your_database > backup.sql
# Restore
psql your_database < backup.sql
API and Integration¶
How do I access the Odoo API?¶
AgriOS uses standard Odoo APIs:
XML-RPC: Available at
/xmlrpc/2/commonand/xmlrpc/2/objectJSON-RPC: Available at
/jsonrpc
Example (Python):
import xmlrpc.client
url = 'https://your-instance.com'
db = 'your_database'
username = 'admin'
password = 'your_password'
common = xmlrpc.client.ServerProxy(f'{url}/xmlrpc/2/common')
uid = common.authenticate(db, username, password, {})
models = xmlrpc.client.ServerProxy(f'{url}/xmlrpc/2/object')
farmers = models.execute_kw(db, uid, password, 'farmer.group', 'search_read',
[[]], {'fields': ['name', 'code']})
How do I integrate with KoBoToolbox?¶
The agrios_kobo module handles KoBoToolbox integration. Configure your KoBo credentials in Settings > KoBoToolbox Integration.
See the agrios_kobo documentation for details.
Testing¶
How do I run tests?¶
# Run all tests for a module
./odoo-bin -i agrios_farmer --test-enable -d test_db --stop-after-init
# Run specific test
./odoo-bin -i agrios_farmer --test-tags agrios_farmer -d test_db --stop-after-init
How do I write tests for my module?¶
Create tests in a tests/ directory:
# tests/__init__.py
from . import test_farmer
# tests/test_farmer.py
from odoo.tests.common import TransactionCase
class TestFarmer(TransactionCase):
def test_create_farmer(self):
farmer = self.env['farmer.group'].create({
'name': 'Test Farmer',
})
self.assertEqual(farmer.name, 'Test Farmer')
Troubleshooting¶
My module changes aren’t showing up¶
Restart the Odoo server
Update the module: Settings > Apps > Update Apps List
Clear browser cache
Check for Python syntax errors in the logs
I get a “field not found” error after adding a new field¶
Update the module to apply database changes
If that doesn’t work, restart Odoo with
-u your_module
How do I debug Odoo code?¶
Enable developer mode in Odoo settings
Use Python’s
pdboripdb:import pdb; pdb.set_trace()
Check Odoo logs for error messages
Use
_logger.info()for logging
Getting Help¶
Documentation: This documentation site
Odoo Documentation: https://www.odoo.com/documentation/
GitHub Issues: https://github.com/advanceinsight/AgriOS/issues
Commercial Support: Contact Advance Insight