Skip to content

Development Workflow

Environment Setup

Prerequisites

  • Python 3.8+ (Odoo 18 requirement)
  • PostgreSQL 12+
  • Git
  • Docker (optional, for isolated testing)

Local Development Setup

# Clone repositories
git clone <cnf-custom-modules-repo> CNFOdooCustomModules
git clone <odoo-18-repo> odoo_18

# Create virtual environment
python3 -m venv venv-odoo18
source venv-odoo18/bin/activate

# Install Odoo dependencies
pip install -r odoo_18/requirements.txt
pip install -r CNFOdooCustomModules/requirements.txt

Database Setup

# Create test database
createdb cnf_odoo18_test

# Copy production data (sanitized)
pg_dump cnf_odoo13_prod | psql cnf_odoo18_test

Module Upgrade Process

1. Assessment Phase

# Check module in v13 environment
./odoo-bin shell -d cnf_odoo13_test
>>> module = env['ir.module.module'].search([('name', '=', 'module_name')])
>>> print(module.dependencies_id.mapped('name'))

2. Code Migration

Common Changes Required

Python 3 Compatibility

# Old (v13)
from urllib import quote

# New (v18)
from urllib.parse import quote

API Changes

# Old (v13)
@api.multi
def action_confirm(self):
    for record in self:
        # logic

# New (v18)
def action_confirm(self):
    for record in self:
        # logic

Field Definitions

# Old (v13)
field_name = fields.Char(string="Name", required=True)

# New (v18) - mostly the same, but check for deprecated parameters
field_name = fields.Char(string="Name", required=True)

3. Testing Phase

Unit Testing

# Run module-specific tests
./odoo-bin test -i module_name -d test_db --stop-after-init

# Run with coverage
coverage run ./odoo-bin test -i module_name
coverage report

Integration Testing

  1. Install module in clean database
  2. Test with dependencies
  3. Verify data migration
  4. Check performance

4. Documentation Updates

Update module README with: - Odoo 18 compatibility notes - Migration steps performed - Breaking changes - New features/improvements

Git Workflow

Branch Strategy

# Create feature branch
git checkout -b upgrade/module_name_v18

# Make changes
git add .
git commit -m "feat: upgrade module_name to Odoo 18

- Update API calls for v18 compatibility
- Fix deprecated decorators
- Update manifest version"

# Push for review
git push origin upgrade/module_name_v18

Commit Guidelines

  • feat: New features or major upgrades
  • fix: Bug fixes
  • refactor: Code improvements
  • docs: Documentation updates
  • test: Test additions/modifications

Code Review Checklist

Before Submitting

  • [ ] Module installs without errors
  • [ ] All tests pass
  • [ ] Dependencies are correct
  • [ ] No hardcoded values
  • [ ] Security rules updated
  • [ ] Views render correctly
  • [ ] Performance acceptable

Review Focus Areas

  1. API Compatibility - All v18 APIs used correctly
  2. Security - Access rights and record rules
  3. Performance - No N+1 queries, efficient searches
  4. UI/UX - Views work on all devices
  5. Data Migration - Existing data preserved

Staging Deployment

Pre-deployment

# Update module list
./odoo-bin update-list -d staging_db

# Test upgrade
./odoo-bin -u module_name -d staging_db --stop-after-init

Deployment Steps

  1. Backup staging database
  2. Deploy code to staging
  3. Run update command
  4. Verify functionality
  5. Run automated tests
  6. User acceptance testing

Troubleshooting

Common Issues

Import Errors

# Check for moved imports
try:
    from odoo.addons.base.models.res_partner import ResPartner
except ImportError:
    from odoo.addons.base.models.res_partner import Partner as ResPartner

View Errors

<!-- Check for deprecated attributes -->
<!-- Old -->
<field name="field" position="after" />

<!-- New - same, but verify in v18 docs -->
<field name="field" position="after" />

JavaScript/Assets - Check for changes in asset bundle names - Update paths in manifest.py - Verify QWeb templates

Performance Optimization

Database Indexes

# Add indexes for frequently searched fields
_sql_constraints = [
    ('code_unique', 'UNIQUE(code)', 'Code must be unique'),
]

# Or in field definition
code = fields.Char(string="Code", index=True)

Batch Processing

# Use batch processing for large datasets
for batch in self.split_every(1000):
    batch.process_records()
    self.env.cr.commit()

Module Status Updates

After completing work: 1. Update modules 4.csv with results 2. Document any issues found 3. Note performance improvements 4. Record testing outcomes

Getting Help

  • Check Odoo 18 official documentation
  • Review similar modules already upgraded
  • Ask in team chat for complex issues
  • Consult third-party vendor docs for their modules