Helps migrate Odoo modules and customizations between versions, specifically focusing on upgrades to/from Odoo 16.0...
This skill provides guidance for migrating Odoo modules between versions, with specialized knowledge of Odoo 16.0 changes, API differences, and upgrade procedures.
Migrating modules from older versions (14.0, 15.0) to 16.0.
Preparing modules for future Odoo versions.
Determining what changes are needed for version compatibility.
Ask for:
Review:
Provide step-by-step migration guide.
1. Python Version
2. Manifest Changes
# Odoo 15 and earlier
{
'version': '15.0.1.0.0',
'depends': ['base', 'stock'],
'license': 'LGPL-3',
}
# Odoo 16.0
{
'version': '16.0.1.0.0', # Updated version
'depends': ['base', 'stock'],
'license': 'LGPL-3',
# New optional keys
'assets': { # Replaces some XML asset declarations
'web.assets_backend': [
'module/static/src/**/*',
],
},
}
3. Stock Valuation Changes
# Odoo 15
class StockMove(models.Model):
_inherit = 'stock.move'
def _create_account_move_line(self):
# Old method signature
pass
# Odoo 16
class StockMove(models.Model):
_inherit = 'stock.move'
def _create_account_move_line(self, credit_account_id, debit_account_id, journal_id, qty, description, svl_id, cost):
# Updated method signature with more parameters
pass
4. Widget Changes
<!-- Odoo 15 -->
<field name="amount" widget="monetary" options="{'currency_field': 'currency_id'}"/>
<!-- Odoo 16 - Same, but some widgets renamed or removed -->
<field name="amount" widget="monetary" options="{'currency_field': 'currency_id'}"/>
5. Removed/Deprecated Methods
_update_average_price() - Replaced with new accounting methods# Step 1: Update version number
'version': '16.0.1.0.0',
# Step 2: Check dependencies
# Ensure all depends modules are compatible with Odoo 16
# Step 3: Update data files if needed
'data': [
'security/ir.model.access.csv',
'views/views.xml',
# Remove any deprecated files
],
# Step 4: Move assets if needed
'assets': {
'web.assets_backend': [
'module_name/static/src/js/*.js',
],
},
# Check for removed fields in base models
# Example: If inheriting stock.move, check release notes
class StockMove(models.Model):
_inherit = 'stock.move'
# Update field definitions if base definition changed
custom_field = fields.Char(...)
# Update method signatures to match new base methods
def _action_done(self, cancel_backorder=False):
# Match new signature
return super()._action_done(cancel_backorder=cancel_backorder)
<!-- Check for removed/renamed view references -->
<record id="view_form" model="ir.ui.view">
<field name="inherit_id" ref="stock.view_move_form"/>
<!-- Update XPath if base view structure changed -->
<field name="arch" type="xml">
<xpath expr="//field[@name='product_id']" position="after">
<field name="custom_field"/>
</xpath>
</field>
</record>
# migrations/16.0.1.0.0/pre-migrate.py
def migrate(cr, version):
"""Pre-migration script for 16.0.1.0.0"""
# Update data before module upgrade
cr.execute("""
UPDATE model_table
SET new_field = old_field
WHERE new_field IS NULL
""")
# migrations/16.0.1.0.0/post-migrate.py
def migrate(cr, version):
"""Post-migration script for 16.0.1.0.0"""
from odoo import api, SUPERUSER_ID
env = api.Environment(cr, SUPERUSER_ID, {})
# Recompute fields
records = env['model.name'].search([])
records._compute_field_name()
# Clean up old data
old_records = env['old.model'].search([])
old_records.unlink()
# Update test imports if needed
from odoo.tests import TransactionCase # Unchanged
class TestModule(TransactionCase):
def setUp(self):
super().setUp()
# Update test data for new field requirements
def test_feature(self):
# Update assertions for new behavior
record = self.env['model.name'].create({
'name': 'Test',
# Add new required fields for Odoo 16
})
self.assertTrue(record)
Major Changes:
Steps:
__manifest__.py version to 16.0.x.x.xMajor Changes:
Steps:
# Create migration script directory
mkdir -p module_name/migrations/16.0.1.0.0
# Test migration on copy of database
pg_dump production_db > backup.sql
createdb test_migration_db
psql test_migration_db < backup.sql
# Run Odoo with migration
python3 src/odoo-bin -c src/odoo.conf \
-d test_migration_db \
-u module_name \
--stop-after-init
# Check logs for errors
tail -f /var/log/odoo/odoo.log | grep ERROR
Error: Field 'xyz' does not exist
Solution: Add field to model or remove from views
TypeError: method() takes X positional arguments but Y were given
Solution: Update method call to match new signature
Error: View inheritance may not use attribute: ...
Solution: Update XPath or view structure
Error: Module 'xyz' not found
Solution: Update dependency version or find replacement
# Run all tests
python3 src/odoo-bin -c src/odoo.conf \
-d DATABASE_NAME \
--test-enable \
--stop-after-init \
-u module_name
# Check specific functionality
python3 src/odoo-bin shell -c src/odoo.conf -d DATABASE_NAME
>>> env['model.name'].search([]).read()
>>> # Test key functionality manually
Comprehensive list of changes introduced in Odoo 16.0 affecting common modules and customizations.
Detailed API changes by module (stock, account, sale, etc.) between Odoo versions.
Template for creating migration scripts with common patterns and examples.