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
This commit is contained in:
Sergi Almacellas Abellana committed 2018-03-02 14:21:17 +01:00
1 parent ff2bded417
commit 6d39f13489
2 files changed
+25 -2

No files matched your search

+6
View File
@@ -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
+19 -2
View File
@@ -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'