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.

Configuration changes

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.

Custom modules

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/

The upgrade

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:

$ trytond-admin --verbose --config trytond.conf --database <dbname> --all

Running the above commands yields:

Traceback (most recent call last):
  File "/path/to/tryton/venv/bin/trytond-admin", line 21, in <module>
    admin.run(options)
  File "/path/to/tryton/venv/local/lib/python2.7/site-packages/trytond/admin.py", line 48, in run
    Pool(db_name).init(update=options.update, lang=lang)
  File "/path/to/tryton/venv/local/lib/python2.7/site-packages/trytond/pool.py", line 155, in init
    lang=lang)
  File "/path/to/tryton/venv/local/lib/python2.7/site-packages/trytond/modules/__init__.py", \
      line 429, in load_modules
    _load_modules()
  File "/path/to/tryton/venv/local/lib/python2.7/site-packages/trytond/modules/__init__.py", \
      line 396, in _load_modules
    graph = create_graph(module_list)[0]
  File "/path/to/tryton/venv/local/lib/python2.7/site-packages/trytond/modules/__init__.py",
       line 191, in create_graph
    - set((p[0] for p in packages))))
Exception: Missing dependencies: [u'purchase_request']

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):

$ trytond-admin --verbose --config trytond.conf --database <dbname> -u purchase_request --all

Subsequent invocations do not require the -u purchase_request parameter.

Now, the upgrade completes but spits out the following warning several times:

WARNING trytond.modules.product.product The column "category" on table \
  "product_template" must be dropped manually

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:

ALTER TABLE product_template DROP COLUMN category;

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):

DELETE FROM ir_module WHERE name='webdav';

After the upgrade

Usability improvements

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.

Product categories

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).

Additional information

Until next time.