Dealing with legacy code always adds an interesting twist to the development process. Over the past few days, I’ve embarked on setting up a development environment for a legacy Odoo 10 modules codebase (mind you, Odoo 17 is already out as I write this). Let me tell you, it’s been quite an ordeal!
Here are the challenges I faced:
Python 2.7 Compatibility
Odoo 10 operates on Python 2.7, which significantly impacts package installations via PIP. Most packages either outright reject installation due to “unsupported” versions or clash with other necessary packages. Precise version numbering becomes critical in this scenario.
Compatibility with arm64 Architecture
Installing old packages in the .Dockerfile posed a significant hurdle due to their incompatibility with my arm64 architecture. While some Debian packages catered to this architecture, not all did. To resolve this, I activated Docker Desktop’s ‘Use Rosetta x86/amd64 emulation for Apple Silicon’ feature and added ‘–platform=linux/amd64’ to the ‘FROM’ section at the top of the .Dockerfile.
Custom Module Dependencies
Certain custom modules required additional PIP packages like Numpy, Pandas, etc. Integrating these posed a challenge because simply adding a ‘RUN pip install whatever’ line in the .Dockerfile wasn’t sufficient to install them in the correct location for Odoo to recognize. I initially attempted setting up a virtual environment for Odoo 10, but found it unnecessary. Instead, ensuring that the installation commands are executed by the same Linux user as the Odoo 10 installation proved effective.
Connecting Odoo 10 to Postgres
Establishing a connection between Odoo 10 and an existing Postgres database mandates that the database username used for connection matches the OWNER of the database. If not, altering the database owner using ‘ALTER DATABASE db_name OWNER TO new_owner_name;’ resolves the issue.
In conclusion, this endeavor not only enhanced my understanding of Odoo 10 but also deepened my knowledge of Docker. For those interested, the Dockerfile is accessible on GitHub at https://github.com/mmahgoub/docker-odoo10