Skip to content

Commit

Permalink
Improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben1700 committed Oct 24, 2024
1 parent 6713c53 commit a7d1d03
Showing 1 changed file with 34 additions and 14 deletions.
48 changes: 34 additions & 14 deletions oopgrade/oopgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,35 +432,55 @@ def remove_wizard(cursor, wizard_models):
)

# Shortcuts
cursor.execute("DELETE from ir_ui_view_sc where view_id in "
"(select id from ir_ui_view where model = '{}')".format(model))
cursor.execute("select id from ir_ui_view where model = '{}'".format(model))
data_records = cursor.fetchall()
record_ids = [record[0] for record in data_records]
if record_ids:
cursor.execute("DELETE from ir_ui_view_sc where view_id in "
"(select id from ir_ui_view where model = '{}')".format(model))

# Actions
cursor.execute(
"DELETE from ir_model_data where model = 'ir.actions.act_window' and res_id in "
"(select id from ir_act_window where res_model = '{}')".format(model))
cursor.execute("select id from ir_act_window where res_model = '{}'".format(model))
data_records = cursor.fetchall()
record_ids = [record[0] for record in data_records]
if record_ids:
cursor.execute(
"DELETE from ir_model_data where model = 'ir.actions.act_window' and res_id in "
"(select id from ir_act_window where res_model = '{}')".format(model))
cursor.execute("DELETE from ir_act_window where res_model = '{}'".format(model))

# Views
cursor.execute(
"DELETE from ir_model_data where model = 'ir.ui.view' and res_id in "
"(select id from ir_ui_view where model = '{}')".format(model))
cursor.execute("select id from ir_ui_view where model = '{}'".format(model))
data_records = cursor.fetchall()
record_ids = [record[0] for record in data_records]
if record_ids:
cursor.execute(
"DELETE from ir_model_data where model = 'ir.ui.view' and res_id in "
"(select id from ir_ui_view where model = '{}')".format(model))
cursor.execute("DELETE from ir_ui_view where model = '{}'".format(model))

# Access rules
cursor.execute(
"DELETE from ir_model_data where model = 'ir.model.access' and res_id in "
"(select id from ir_model_access where model_id = '{}')".format(model_id))
cursor.execute("select id from ir_model_access where model_id = '{}'".format(model_id))
data_records = cursor.fetchall()
record_ids = [record[0] for record in data_records]
if record_ids:
cursor.execute(
"DELETE from ir_model_data where model = 'ir.model.access' and res_id in "
"(select id from ir_model_access where model_id = '{}')".format(model_id))
cursor.execute("DELETE from ir_model_access where model_id = {}".format(model_id))

# Model
cursor.execute("DELETE from ir_model_data where model = 'ir.model' and res_id = {}".format(model_id))
cursor.execute("DELETE from ir_model where id = {}".format(model_id))

# Fields
cursor.execute(
"DELETE from ir_model_data where model = 'ir.model.fields' and res_id in "
"(select id from ir_model_fields where model_id = '{}')".format(model_id))
cursor.execute("select id from ir_model_fields where model_id = '{}'".format(model_id))
data_records = cursor.fetchall()
record_ids = [record[0] for record in data_records]
if record_ids:
cursor.execute(
"DELETE from ir_model_data where model = 'ir.model.fields' and res_id in "
"(select id from ir_model_fields where model_id = '{}')".format(model_id))


def clean_old_wizard(cr, old_wizard_name, module):
Expand Down

0 comments on commit a7d1d03

Please sign in to comment.