Skip to content

Commit

Permalink
Merge pull request #45 from gisce/remove_shortcuts_on_delete_record
Browse files Browse the repository at this point in the history
Eliminar los shortcuts de las vistas a eliminar
  • Loading branch information
polsala authored Aug 7, 2024
2 parents b1617e5 + fdd7179 commit 94af166
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions oopgrade/oopgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,26 @@ def delete_record(cursor, module_name, record_names):
# It should have only one.
if model_data_vs and len(model_data_vs) == 1:
model_data_vs = model_data_vs[0]
if model_data_vs['model'] == 'ir.ui.view':
# Delete all shortcuts that use this view
sql_sc_search = """
SELECT id
FROM ir_ui_view_sc
WHERE view_id = %(sc_view_id)s
"""
params_sc_id = {
'sc_view_id': model_data_vs['res_id']
}
cursor.execute(sql_sc_search, params_sc_id)
view_id_to_delete = cursor.dictfetchall()[0]
if view_id_to_delete:
sql_sc_del = """
DELETE FROM ir_ui_view_sc WHERE id = %(sc_view_id)s
"""
params_sc_del = {
'sc_view_id': view_id_to_delete['id']
}
cursor.execute(sql_sc_del, params_sc_del)
# Delete from model data.
sql_model_del = """
DELETE FROM ir_model_data WHERE id = %(model_data_id)s
Expand Down

0 comments on commit 94af166

Please sign in to comment.