From 6d39f13489dd3cd298b33cd2e01614d203dcc8f6 Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Fri, 2 Mar 2018 14:21:17 +0100 Subject: [PATCH] Add migration to register buttons on ir module changeset 83757dc87808 moved the buttons from res to ir module but it missed the migration of the model data to allow updates from previous databases issue7186 review38031003 --- trytond/ir/model.py | 6 ++++++ trytond/ir/module.py | 21 +++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/trytond/ir/model.py b/trytond/ir/model.py index 266b1308ff..9ec296793d 100644 --- a/trytond/ir/model.py +++ b/trytond/ir/model.py @@ -1087,6 +1087,12 @@ class ModelData(ModelSQL, ModelView): where=model_data.inherit == True)) table.drop_column('inherit', True) + # Migration from 4.6: register buttons on ir module + cursor.execute(*model_data.update( + [model_data.module], ['ir'], + where=((model_data.module == 'res') + & (model_data.fs_id == 'model_data_sync_button')))) + @staticmethod def default_noupdate(): return False diff --git a/trytond/ir/module.py b/trytond/ir/module.py index f12e65bd2c..8888d2bba1 100644 --- a/trytond/ir/module.py +++ b/trytond/ir/module.py @@ -102,7 +102,12 @@ class Module(ModelSQL, ModelView): @classmethod def __register__(cls, module_name): + pool = Pool() + ModelData = pool.get('ir.model.data') TableHandler = backend.get('TableHandler') + sql_table = cls.__table__() + model_data_sql_table = ModelData.__table__() + cursor = Transaction().connection.cursor() # Migration from 3.6: remove double module old_table = 'ir_module_module' @@ -112,8 +117,6 @@ class Module(ModelSQL, ModelView): super(Module, cls).__register__(module_name) # Migration from 4.0: rename installed to activated - sql_table = cls.__table__() - cursor = Transaction().connection.cursor() cursor.execute(*sql_table.update( [sql_table.state], ['activated'], where=sql_table.state == 'installed')) @@ -121,6 +124,20 @@ class Module(ModelSQL, ModelView): [sql_table.state], ['not activated'], where=sql_table.state == 'uninstalled')) + # Migration from 4.6: register buttons on ir module + button_fs_ids = [ + 'module_activate_button', + 'module_activate_cancel_button', + 'module_deactivate_button', + 'module_deactivate_cancel_button', + 'module_upgrade_button', + 'module_upgrade_cancel_button', + ] + cursor.execute(*model_data_sql_table.update( + [model_data_sql_table.module], ['ir'], + where=((model_data_sql_table.module == 'res') + & (model_data_sql_table.fs_id.in_(button_fs_ids))))) + @staticmethod def default_state(): return 'not activated'