Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliminar los shortcuts de las vistas a eliminar #45

Merged
merged 6 commits into from
Aug 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading