Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
For the sake of consistency, the module ups was renamed to shipping_ups. Tryton's migration API does not provide a straightforward way to rename modules as its an exceptional case. This file gives you the code you need to make the migration
# -*- coding: utf-8 -*-
import os
import psycopg2
# Connect to tryton database with database uri.
# Example: postgres://tryton:tryton@localhost/production
conn = psycopg2.connect(os.environ.get('TRYTOND_DATABASE_URI'))
def rename_ups_module():
"""UPS module has been renamed to shipping_ups, hence rename it in
database also.
# Update ir_module_module entry.
# Just a name change from `ups` to `shipping_ups`
UPDATE ir_module_module
SET name = 'shipping_ups'
WHERE name = 'ups'
# Update data related to ups
# Tryton stores the information about records created from
# XML in, so it can update the information
# with module upgrades.
# Update the name of module there too.
UPDATE ir_model_data
SET module = 'shipping_ups'
WHERE module = 'ups';
# Tryton views store the module name in them to load the
# view xml filed from FS at runtime. They need to be update
# too
UPDATE ir_ui_view
SET module = 'shipping_ups'
WHERE module = 'ups';
if __name__ == '__main__':
cursor = conn.cursor()

This comment has been minimized.

Copy link
Owner Author

@sharoonthomas sharoonthomas commented Mar 27, 2015

Usage instructions:

  1. Set the database connection as a URI in the environment
export TRYTOND_DATABASE_URI=postgres://tryton:tryton@localhost/production
  1. Run the file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.