Skip to content

Commit

Permalink
Merge pull request #39 from gisce/fix/51306_clean_old_wizard
Browse files Browse the repository at this point in the history
Mejoras clean_old_wizard eliminar menús
  • Loading branch information
ecarreras authored Feb 5, 2024
2 parents bcfcb43 + 0cf7806 commit 88b8df5
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions oopgrade/oopgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,16 +397,15 @@ def clean_old_wizard(cr, old_wizard_name, module):
model_id = cr.fetchone()

sql_value = """
SELECT id
SELECT id, model, res_id
FROM ir_values
WHERE value = 'ir.actions.wizard,%(wiz_id)s'
WHERE value = 'ir.actions.wizard,' || %(wiz_id)s
"""
params_value = {
'wiz_id': wiz_id
}
cr.execute(sql_value, params_value)
value_id = cr.fetchone()

values_datas = cr.dictfetchall()
sql_del_wiz = """
DELETE FROM ir_act_wizard WHERE id in %(wiz_id)s;
"""
Expand All @@ -425,14 +424,27 @@ def clean_old_wizard(cr, old_wizard_name, module):
}
cr.execute(sql_del, params_del)

if value_id and len(value_id) == 1:
for value_data in values_datas:
sql_del = """
DELETE FROM ir_value WHERE id in %(value_id)s
DELETE FROM ir_values WHERE id = %(value_id)s
"""
params_del = {
'value_id': value_id
'value_id': value_data['id']
}
cr.execute(sql_del, params_del)
# the associated menus of the old wizard are also deleted if any
if value_data['model'] == 'ir.ui.menu':
sql_del_menu = """
DELETE
FROM ir_ui_menu
WHERE id = %(menu_id)s;
DELETE
FROM ir_model_data
WHERE res_id = %(menu_id)s
AND model = 'ir.ui.menu';
"""
cr.execute(sql_del_menu, {'menu_id': value_data['res_id']})


def set_defaults(cr, pool, default_spec, force=False):
"""
Expand Down

0 comments on commit 88b8df5

Please sign in to comment.