Skip to content
Odoo Migration

Navigating Custom Code Refactoring for Odoo 17 to 18 Migration

A practical guide for CIOs and IT leaders on managing custom code refactoring during the Odoo 17 to 18 upgrade, covering dependency analysis, API changes, testing strategies, and risk mitigation.

12 min readSysGenPro Editorial
Navigating Custom Code Refactoring for Odoo 17 to 18 Migration

Navigating custom code refactoring for the Odoo 17 to 18 migration requires a structured, phased approach that prioritizes dependency analysis, API compatibility verification, and rigorous testing before any production cutover. The primary risk is not the core database upgrade itself, but the silent failure of custom modules and third-party add-ons that rely on deprecated APIs or changed model structures. To mitigate this, organizations must treat the upgrade as a software development project rather than a simple version bump. This involves auditing all custom code against the Odoo 18 release notes, refactoring incompatible logic, and validating changes in a representative staging environment. The goal is to ensure that business processes remain uninterrupted while taking advantage of the new version's features and security improvements. Failure to properly manage custom code refactoring can lead to data loss, broken workflows, and significant downtime, making a disciplined methodology essential for success.

Phase 1: Preparation and Dependency Analysis

The first step in any Odoo version upgrade is a comprehensive audit of the current system. This phase is critical for identifying all custom modules, third-party add-ons, and integrations that will be affected by the move from version 17 to 18. You must create a complete inventory of all installed modules, distinguishing between core Odoo modules, enterprise modules, and custom-developed code. For each custom module, document its dependencies on specific Odoo APIs, models, fields, and views. This dependency map serves as the foundation for your refactoring strategy. It is crucial to verify the compatibility of all third-party add-ons with Odoo 18 by checking the vendor's official documentation and release notes. Do not assume that an add-on compatible with Odoo 17 will automatically work in Odoo 18. If a vendor has not released an Odoo 18-compatible version, you must plan for either a custom patch, a replacement solution, or a temporary workaround. This phase also involves setting up a dedicated staging environment that mirrors the production database structure and data volume as closely as possible. This environment will be used for all testing and validation activities, ensuring that the production upgrade is as predictable as possible.

Identifying Deprecated APIs and Model Changes

Odoo releases often introduce changes to the Object-Relational Mapping (ORM) layer, view inheritance mechanisms, and security rules. During the preparation phase, developers must review the Odoo 18 release notes and technical documentation to identify any deprecated methods, removed fields, or changed model behaviors. Common areas of change include the handling of computed fields, the structure of XML views, and the implementation of access rights. Use static code analysis tools to scan your custom codebase for calls to deprecated APIs. While these tools can identify potential issues, they cannot guarantee compatibility, so manual code review is still necessary. Pay special attention to any custom Python code that directly manipulates the database or bypasses the ORM, as these are high-risk areas that often break during version upgrades. Document all identified issues in a tracking system, assigning ownership and priority to each item. This creates a clear roadmap for the refactoring work and ensures that no critical issue is overlooked.

Phase 2: Technical Execution and Code Refactoring

Once the dependency analysis is complete, the technical execution phase begins. This involves refactoring custom code to align with the Odoo 18 architecture. Refactoring should be done in small, manageable increments, with each change committed to version control and tested in the staging environment. Start with the most critical modules that impact core business processes, such as sales, inventory, and accounting. For each module, update the code to use the new APIs, adjust view definitions to match any changes in the core module structure, and update security rules to reflect any changes in the permission model. It is important to maintain backward compatibility where possible, but do not hesitate to rewrite code that is overly complex or relies on fragile workarounds. This is an opportunity to reduce technical debt and improve the maintainability of your custom code. Ensure that all refactored code follows Odoo's coding standards and best practices. This not only improves code quality but also makes future upgrades easier. During this phase, you should also update any integration scripts or middleware that connect Odoo to external systems. These integrations often rely on specific API endpoints or data formats that may have changed in Odoo 18. Test these integrations thoroughly in the staging environment to ensure that data flows correctly between systems.

Managing Third-Party Add-on Compatibility

Third-party add-ons present a unique challenge during Odoo upgrades. Unlike custom code, you do not have full control over the source code of these modules. If a vendor has not released an Odoo 18-compatible version, you must evaluate the risk of using the Odoo 17 version in an Odoo 18 environment. In many cases, this will result in errors or unexpected behavior. Your options include contacting the vendor for a patch, developing a custom compatibility layer, or replacing the add-on with an alternative solution. If you choose to develop a custom patch, ensure that it is well-documented and tested. If you choose to replace the add-on, plan for the data migration and process changes that may be required. It is important to communicate these decisions to all stakeholders, as they may impact business operations. Do not proceed with the upgrade until all critical third-party add-ons are either compatible or have a viable workaround in place. This phase requires close coordination between your internal development team and external vendors to ensure that all dependencies are resolved.

Phase 3: Validation and Testing Strategy

Testing is the most critical phase of the Odoo 17 to 18 migration. A comprehensive testing strategy must include unit tests, integration tests, end-to-end business process tests, and user acceptance testing (UAT). Unit tests should be written for all custom Python code to ensure that individual functions behave as expected. Integration tests should verify that custom modules interact correctly with core Odoo modules and other custom modules. End-to-end business process tests should simulate real-world scenarios, such as creating a sales order, receiving inventory, and generating an invoice. These tests should be performed in the staging environment using a representative dataset. User acceptance testing involves key business users validating that the system meets their requirements and that their workflows are not disrupted. It is important to involve users early in the testing process to identify any usability issues or functional gaps. Additionally, perform performance testing to ensure that the upgraded system can handle the expected load. Compare performance metrics before and after the upgrade to identify any regressions. Finally, conduct security checks to ensure that access rights and data protection measures are intact. Document all test results and any defects found. Defects should be triaged and fixed before proceeding to the next phase.

Test TypePurposeKey ActivitiesResponsible Role
Unit TestsVerify individual code functionsRun automated tests on custom Python codeDevelopment Team
Integration TestsVerify module interactionsTest data flow between custom and core modulesQA Team
End-to-End TestsSimulate business processesExecute full workflows in staging environmentQA Team
User Acceptance TestingValidate business requirementsKey users test critical workflowsBusiness Stakeholders
Performance TestsEnsure system scalabilityBenchmark load and response timesIT Operations

Phase 4: Deployment and Cutover Planning

Once all testing is complete and defects are resolved, you can proceed to the deployment phase. Cutover planning is essential to minimize downtime and ensure a smooth transition to the new version. Define a clear cutover window, taking into account business hours and operational constraints. Prepare a detailed runbook that outlines every step of the upgrade process, including database backups, code deployment, database migration, and system validation. Assign specific roles and responsibilities to each team member. Establish go/no-go criteria that must be met before proceeding with the cutover. These criteria should include successful completion of all critical tests, confirmation of data integrity, and sign-off from key stakeholders. Have a rollback plan in place in case the upgrade fails. The rollback plan should include steps to restore the database from a backup and revert the code to the previous version. Test the rollback plan in the staging environment to ensure that it works as expected. Communicate the cutover schedule and any expected downtime to all users and stakeholders. During the cutover, monitor the system closely for any errors or unexpected behavior. If any critical issues arise, trigger the rollback plan immediately. Do not attempt to fix issues in production unless they are minor and can be resolved quickly.

Database Migration and Data Integrity

The database migration is a critical component of the Odoo upgrade. Odoo uses PostgreSQL as its database, and the upgrade process involves applying schema changes to the database. Before performing the migration, take a full backup of the production database. Verify that the backup is complete and can be restored. In the staging environment, perform a trial migration to identify any potential issues with the database schema. Check for any data inconsistencies or errors that may have been introduced by the migration. After the migration, run data integrity checks to ensure that all records are present and that relationships between tables are intact. Compare key data points, such as total sales, inventory levels, and customer counts, before and after the migration to verify accuracy. If any discrepancies are found, investigate and resolve them before proceeding to the next step. It is important to document the results of the data integrity checks and include them in the go/no-go decision. Data loss or corruption during an ERP upgrade can have severe consequences for the business, so this phase must be handled with extreme care.

Phase 5: Post-Migration Stabilization

After the successful deployment of Odoo 18, the post-migration stabilization phase begins. This phase involves monitoring the system for any issues that may not have been detected during testing. Set up enhanced monitoring and logging to track system performance, error rates, and user activity. Establish a support channel for users to report any issues or questions. Assign a dedicated team to handle support requests and resolve any defects that arise. Monitor key business metrics to ensure that operations are running smoothly. Compare these metrics to pre-upgrade baselines to identify any deviations. If any issues are found, prioritize them based on their impact on business operations and resolve them as quickly as possible. Continue to monitor the system for at least two weeks after the upgrade, as some issues may only appear under specific conditions or after a certain volume of transactions. Document all issues and resolutions to create a knowledge base for future reference. Finally, conduct a post-mortem review to identify what went well and what could be improved in future upgrades. Use the lessons learned to refine your migration strategy and improve the efficiency of future version upgrades.

  • Monitor system performance and error rates daily for the first two weeks.
  • Establish a dedicated support channel for user queries and issue reporting.
  • Compare key business metrics to pre-upgrade baselines to identify deviations.
  • Document all issues and resolutions to create a knowledge base.
  • Conduct a post-mortem review to identify areas for improvement.

Risk Management and Mitigation Strategies

Effective risk management is essential for a successful Odoo 17 to 18 migration. The primary risks include data loss, downtime, broken customizations, unsupported dependencies, integration failures, and security misconfiguration. To mitigate these risks, implement a comprehensive risk management plan that identifies potential risks, assesses their likelihood and impact, and defines mitigation strategies. For data loss, ensure that regular backups are taken and that restore tests are performed. For downtime, plan the cutover during a low-activity period and have a rollback plan in place. For broken customizations, perform thorough testing in a staging environment and have a team of developers on standby to fix any issues. For unsupported dependencies, verify the compatibility of all third-party add-ons and have alternative solutions ready. For integration failures, test all integrations in the staging environment and have a manual workaround in place. For security misconfiguration, perform security checks and ensure that access rights are correctly configured. By proactively managing these risks, you can minimize the impact of any issues that arise during the migration and ensure a smooth transition to Odoo 18.

RiskImpactMitigation StrategyOwner
Data LossHighRegular backups and restore testsIT Operations
DowntimeMediumPlan cutover during low-activity periodProject Manager
Broken CustomizationsHighThorough testing in staging environmentDevelopment Team
Unsupported DependenciesMediumVerify add-on compatibility and have alternativesERP Consultant
Integration FailuresHighTest integrations and have manual workaroundsIntegration Team

Conclusion: Ensuring Long-Term ERP Maintainability

Navigating custom code refactoring for the Odoo 17 to 18 migration is a complex but manageable process if approached with discipline and planning. By following a structured methodology that includes preparation, technical execution, validation, deployment, and stabilization, you can minimize risks and ensure a successful upgrade. The key to success is to treat the upgrade as a software development project, with a focus on dependency analysis, code refactoring, and rigorous testing. Do not underestimate the impact of custom code and third-party add-ons on the upgrade process. Verify the compatibility of all components and have a plan in place for any issues that arise. By taking a proactive approach to risk management and ensuring that all stakeholders are aligned, you can achieve a smooth transition to Odoo 18 and position your organization for long-term ERP maintainability. Remember to check the official Odoo documentation for the exact source and target versions to verify compatibility and support details. This guide provides a general framework, but the specific details of your migration will depend on your unique environment and requirements.

Written by
SysGenPro Editorial

SysGenPro Editorial

Platform & solutions team

Practical guidance on ERP, AI automation, cloud deployment and enterprise transformation from the SysGenPro team.

Share this article

Frequently asked questions

Common questions on this topic. Talk to our team for anything specific to your business.

01What are the main API changes between Odoo 17 and 18?

Specific API changes vary by release. You must consult the official Odoo 18 release notes and technical documentation to identify deprecated methods, removed fields, or changed model behaviors. Common areas of change include ORM layer updates, view inheritance mechanisms, and security rule implementations.

02How do I test custom modules before the final upgrade?

Set up a staging environment that mirrors production. Perform unit tests, integration tests, and end-to-end business process tests. Use a representative dataset and involve key business users in user acceptance testing to validate workflows.

03Can I upgrade Odoo 17 to 18 without refactoring custom code?

It is unlikely. Most custom code will require some level of refactoring to align with the new version's APIs and architecture. Even minor changes in core modules can break custom code that relies on specific behaviors or structures.

04What is the recommended rollback strategy for Odoo upgrades?

Take a full backup of the database and code before the upgrade. Test the restore process in a staging environment. Define clear go/no-go criteria and have a documented rollback plan that includes steps to restore the database and revert the code.

05How long does an Odoo version upgrade typically take?

The duration depends on the complexity of your custom code, the number of third-party add-ons, and the size of your database. A simple upgrade may take a few days, while a complex one with extensive customizations can take several weeks.

06Do third-party add-ons need to be updated before the core upgrade?

Yes. Verify the compatibility of all third-party add-ons with Odoo 18. If a vendor has not released a compatible version, you must plan for a custom patch, a replacement solution, or a temporary workaround before proceeding with the core upgrade.

Continue learning
View all articles
Explore the platform

Where to go next

Browse the knowledge hub

See how SysGenPro fits your business

Discuss your workflows, modules and deployment options with our team.

Back to resources