summaryrefslogtreecommitdiff
path: root/addons/base_import_module
diff options
context:
space:
mode:
authorDamien Bouvy <dbo@odoo.com>2019-11-08 20:33:25 +0000
committerDamien Bouvy <dbo@odoo.com>2019-12-20 11:16:01 +0000
commit59eee6ba5fed0ba74221f44a296ec6efedbc2527 (patch)
tree2882272edff00cc0550faf33d6b4f8617c8912fb /addons/base_import_module
parent220eb4db391d8ba49dd26bdd3d8af1c27b433d78 (diff)
[IMP] base_import_module: clean up after itself
Uninstalling an imported module leaves behind an ir.module.module entry which is entirely useless: it cannot be reinstalled without re-uploading the module. A quick solution is provided here by simply cleaning up after the uninstallation and deleting the ir.module.module records of imported modules that just got removed. Another possibility could be to store the uploaded module for good in an attachment and re-load it from there upon re-installation, but that would lead to some conflict with Studio, as uninstalling the studio_customization module usually means you want to get rid of it for good.
Diffstat (limited to 'addons/base_import_module')
-rw-r--r--addons/base_import_module/models/ir_module.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/addons/base_import_module/models/ir_module.py b/addons/base_import_module/models/ir_module.py
index a9d064ad23a..9fff8448ffd 100644
--- a/addons/base_import_module/models/ir_module.py
+++ b/addons/base_import_module/models/ir_module.py
@@ -146,6 +146,19 @@ class IrModule(models.Model):
r.append("Error while importing module '%s'.\n\n %s \n Make sure those modules are installed and try again." % (mod, error))
return '\n'.join(r), module_names
+ def module_uninstall(self):
+ # Delete an ir_module_module record completely if it was an imported
+ # one. The rationale behind this is that an imported module *cannot* be
+ # reinstalled anyway, as it requires the data files. Any attempt to
+ # install it again will simply fail without trace.
+ res = super().module_uninstall()
+ modules_to_delete = self.filtered('imported')
+ if modules_to_delete:
+ _logger.info("deleting imported modules upon uninstallation: %s",
+ ", ".join(modules_to_delete.mapped('name')))
+ modules_to_delete.unlink()
+ return res
+
def _is_studio_custom(path):
"""