[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.
This commit is contained in:
Damien Bouvy
2019-12-20 11:16:01 +00:00
parent 220eb4db39
commit 59eee6ba5f
@@ -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):
"""