Last active
August 29, 2015 14:17
-
-
Save sharoonthomas/d173234e625d5a8ce90a to your computer and use it in GitHub Desktop.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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')) | |
conn.set_client_encoding('UTF8') | |
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` | |
cursor.execute(""" | |
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 ir.model.data, so it can update the information | |
# with module upgrades. | |
# | |
# Update the name of module there too. | |
cursor.execute(""" | |
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 | |
cursor.execute(""" | |
UPDATE ir_ui_view | |
SET module = 'shipping_ups' | |
WHERE module = 'ups'; | |
""") | |
if __name__ == '__main__': | |
cursor = conn.cursor() | |
rename_ups_module() | |
conn.commit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage instructions: