Sitemap

Upgrading an Odoo Module from Version 15 to Version 18: A Step-by-Step Tutorial with Example

3 min readJan 13, 2025
Upgrading an Odoo Module from Version 15 to Version 18: A Step-by-Step Tutorial with Example

Upgrading an Odoo module from version odoo15 to version odoo18 requires careful adjustments to ensure compatibility with changes introduced in newer versions of Odoo. This detailed tutorial provides a step-by-step guide with examples for upgrading your odoo module.

Prerequisites

  1. Odoo 15 module code.
  2. Odoo 18 development environment.
  3. Basic knowledge of Python, XML, and Odoo framework.
  4. Code editor (e.g., VSCode, PyCharm).
  5. Test database for Odoo 18.

Step 1: Set Up the Odoo 18 Development Environment

Ensure you have Odoo 18 installed and running on your system. Use a virtual environment to manage Python dependencies.

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

# Install required Python packages
pip install -r requirements.txt

# Run Odoo 18
python odoo-bin -c your/odoo.config

Step 2: Update the __manifest__.py File

The manifest file contains metadata about your module. You need to update the version number and dependencies.

Original __manifest__.py (Odoo 15):

{
'name': 'Custom Module',
'version': '0.1',
'depends': ['base', 'sale'],
'data': [
'security/ir.model.access.csv',
'views/custom_view.xml',
],
}

Updated __manifest__.py (Odoo 18):

{
'name': 'Custom Module',
'version': '18.0.1.0.0',
'depends': ['base', 'sale'],
'data': [
'security/ir.model.access.csv',
'views/custom_view.xml',
],
'application': True,
}

Changes:

  1. Updated version to 18.0.1.0.0.
  2. Added application key for better module categorization.

Step 3: Update Python Code for Models

Odoo’s ORM may introduce changes in method signatures and field definitions.

Example: Updating a Model

Original Model (models/custom_model.py - Odoo 15):

from odoo import models, fields

class CustomModel(models.Model):
_name = 'custom.model'
_description = 'Custom Model'

name = fields.Char(string='Name', required=True)
amount = fields.Float(string='Amount')

Updated Model (models/custom_model.py - Odoo 18):

from odoo import models, fields, api

class CustomModel(models.Model):
_name = 'custom.model'
_description = 'Custom Model'

name = fields.Char(string='Name', required=True)
amount = fields.Float(string='Amount')
active = fields.Boolean(string='Active', default=True)

@api.model
def create(self, vals):
# Add custom logic if needed
return super(CustomModel, self).create(vals)

Changes:

  1. Added a new field active to align with best practices.
  2. Updated the create method using @api.model decorator.

Step 4: Update XML Files

Changes in the XML structure or field attributes may be required to comply with Odoo 18.

Original View (views/custom_view.xml - Odoo 15):

<odoo>
<record id="view_custom_model_tree" model="ir.ui.view">
<field name="name">custom.model.tree</field>
<field name="model">custom.model</field>
<field name="arch" type="xml">
<tree string="Custom Model">
<field name="name"/>
<field name="amount"/>
</tree>
</field>
</record>
</odoo>

Updated View (views/custom_view.xml - Odoo 18):

<odoo>
<record id="view_custom_model_tree" model="ir.ui.view">
<field name="name">custom.model.tree</field>
<field name="model">custom.model</field>
<field name="arch" type="xml">
<list string="Custom Model">
<field name="name"/>
<field name="amount"/>
<field name="active"/>
</list>
</field>
</record>
</odoo>

Changes:

  1. Added the new active field to the tree view.
  2. Replace your xml treeto list .

Step 5: Update Security Rules

Ensure that access rights and record rules are updated.

Original Security Rule (security/ir.model.access.csv - Odoo 15):

id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_custom_model,access.custom.model,model_custom_model,base.group_user,1,1,1,1

Updated Security Rule (Odoo 18)

No major changes are required unless new groups or models are introduced.

Step 6: Test the Module

  1. Upgrade the module:
python odoo-bin -c your/odoo.config -u custom_module

2. Check logs for any warnings or errors.

3. Test functionality to ensure everything works as expected.

Step 7: Fix Issues and Perform Final Testing

Address any issues encountered during testing, including:

  • Missing fields or views.
  • Incorrect method overrides.
  • Security rule errors.

Step 8: Deploy the Upgraded Module

Once everything is working correctly, deploy the upgraded module to the production environment.

Summary

Upgrading an Odoo module involves:

  1. Updating the manifest file.
  2. Adjusting Python models and methods.
  3. Modifying XML views.
  4. Reviewing and updating security rules.
  5. Thoroughly testing the module.

By following this step-by-step guide, you can upgrade your module from Odoo 15 to Odoo 18 with minimal issues.

Thank you for reading. If you find something wrong or better ways to do it, let me know in the comments below.

If you like the post, hit the 👏 button below so that others may find it useful. You can follow me on

GitHub | daily.dev | LinkedIn | YouTube

--

--

Mehedi Khan
Mehedi Khan

Written by Mehedi Khan

I'm a Software engineer. I'm comfortable with Python, Django, and Full-stack Web Development. Follow To Support Me On Medium 🫠

No responses yet