Notes on upgrading from Tryton 3.8 to Tryton 4.0
written on Friday, August 19, 2016
At work, we wanted to upgrade the Tryton installation from version 3.8 to version 4.0. There is very little information available on how to conduct such upgrades and how to deal with the various errors that pop up during the process. The post starts with notes on some of the changes followed by a description of problems as they emerged during the upgrade and concludes with some required changes after the upgrade.
Before the upgrade
Split of the trytond binary
The trytond executable has been split into multiple distinct executables: trytond-admin, trytond-cron. There is no backwards compatibility layer in the new trytond, so you will quickly notice which scripts need to change as some parameters are no longer accepted by trytond:
- All administrative tasks such as database upgrades are now handled by trytond-admin.
- All background tasks are now handled by trytond-cron and the new trytond no longer accepts the --cron parameter. As such, a new service file is needed to handle background tasks.
The configuration for trytond needs to be adjusted:
- The [jsonrpc] and [xmlrpc] sections have been merged into [web].
- The path to the Tryton web interface (SAO) now uses the configuration key root instead of data. The configuration key is part of the [web] section.
- All connections are now handled by a single port. The separation between JSON-RPC and XML-RPC is gone. This obviously triggers some changes in the nginx configuration as well.
We use several modules that provide custom reports which require some updates:
- Update dependency to Tryton 4.0.
- Rebuild translations as the translation format changed. I actually deleted the translations of the modules exported them again from the test instance.
Tools and scripts
The tools that leverage Proteus to communicate with Tryton require some changes as well:
- Update Proteus to match Tryton 4.0.
- The XML-RPC connection string must end with a /, e.g. https://user:pass@hostname:port/database/
Update Trytond and its modules
To get started, clone the running instance and test the upgrade with the clone. Our Tryton instance is installed in a virtual environment, so I started out by updating the version information in our Ansible role from 3.8 to 4.0 and completed the list of required modules from the official documentation. After that Ansible can create the new virtual environment. Beware to upgrade all custom modules before this step as they need to depend on the new Tryton version.
Run pip freeze | grep "3.8" in the virtual environment to make sure no modules from 3.8 are lingering around.
Upgrading the database
OK, the virtual environment is ready. Let's upgrade the database:
Running the above commands yields:
This error occurs even if the module trytond-purchase-request is installed. The solution is to run the following command instead (with this exact argument order):
Subsequent invocations do not require the -u purchase_request parameter.
Now, the upgrade completes but spits out the following warning several times:
The product categories got overhauled with Tryton 4.0. Tryton already migrated the respective data in the database and now warns us that we should better get rid of the old category column. This warning may be fixed by connecting to the database and do what Tryton suggests:
The database upgrade is now complete. Subsequent invocations do not yield any errors or warnings.
Remove the webdav module
The webdav module is no longer bundled as core module for Tryton 4.0. It is now available as separate module. We never used it, so it is best to remove it altogether. Connect to the database and remove it from the ir_module table (thx @cedk for the hint):
After the upgrade
Tryton 4.0 allows to set default values for several fields. This is really useful as it saves the user a few clicks for each created product and improves data consistency.
The product category was replaced by a categories field. This allows multiple categories per product. A single category is used for accounting.
For our use case we had to update the product categories and the accounting category for all products. I wrote a small migration script that leverages Proteus to update all products (download).
Until next time.