From cedc976238c2da0354668bf7413c7eef6ef9289d Mon Sep 17 00:00:00 2001 From: Carlos Lopez Date: Tue, 11 Mar 2025 10:41:42 -0500 Subject: [PATCH] [FIX] web_ir_actions_act_multi: Uninstallation Issue During uninstallation, Odoo attempts to delete columns and tables related to the ir.actions.act_multi model. However, this model shares the same table (ir_actions) with other core modules, meaning the table and its columns should not be removed. Before this commit, this issue could render the database unusable. After this commit, the database remains intact, and the module can be uninstalled without problems. --- web_ir_actions_act_multi/models/__init__.py | 1 + web_ir_actions_act_multi/models/ir_model.py | 37 +++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 web_ir_actions_act_multi/models/ir_model.py diff --git a/web_ir_actions_act_multi/models/__init__.py b/web_ir_actions_act_multi/models/__init__.py index 16285e5e1..1becfc074 100644 --- a/web_ir_actions_act_multi/models/__init__.py +++ b/web_ir_actions_act_multi/models/__init__.py @@ -1 +1,2 @@ from . import ir_actions +from . import ir_model diff --git a/web_ir_actions_act_multi/models/ir_model.py b/web_ir_actions_act_multi/models/ir_model.py new file mode 100644 index 000000000..3da5fbc2e --- /dev/null +++ b/web_ir_actions_act_multi/models/ir_model.py @@ -0,0 +1,37 @@ +from odoo import api, models + + +class IrModelData(models.Model): + _inherit = "ir.model.data" + + @api.model + def _module_data_uninstall(self, modules_to_remove): + # Set a flag to prevent the deletion of tables and columns + # related to ir.actions.act_multi. + if "web_ir_actions_act_multi" in modules_to_remove: + self = self.with_context(uninstall_web_ir_actions_act_multi=True) + return super(IrModelData, self)._module_data_uninstall(modules_to_remove) + + +class IrModel(models.Model): + _inherit = "ir.model" + + def _drop_table(self): + # Prevent the deletion of the table. + # The model is ir.actions.act_multi, but the actual table is ir_actions. + # This table is a core component and should not be removed. + if self.env.context.get("uninstall_web_ir_actions_act_multi"): + self -= self.filtered(lambda model: model.model == "ir.actions.act_multi") + return super()._drop_table() + + +class IrModelFields(models.Model): + _inherit = "ir.model.fields" + + def _drop_column(self): + # Prevent the deletion of columns in the ir_actions table. + # The model is ir.actions.act_multi, but the actual table is ir_actions. + # Since this table is a core component, its columns should not be deleted. + if self.env.context.get("uninstall_web_ir_actions_act_multi"): + self -= self.filtered(lambda field: field.model == "ir.actions.act_multi") + return super()._drop_column()