From adfec4256100c7bd5cafe8c213f2012f06d8166a Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Fri, 20 Apr 2018 17:27:49 +0200 Subject: [PATCH] [FIX] base_import_module: imported module version - Create a simple module, set version to 2.0 - Import the zip file The 'Latest Version' (field `installed_version`) is set to 11.0.1.0, while one would expect 11.0.2.0. There are several reasons for this. First, the method `get_values_from_terp` doesn't return the version, so at this point the information is already lost. Then, the field `installed_version` is a computed field which retrieves the version from the `__manifest__.py` file. In the case of an imported module, there is no such file in which we can look up for the value (even though the imported module contained one). To avoid this, we explicitly set the 'Installed Version' (field `latest_version`) to the version retrieved at import. Since this field refers to the version installed in the database, it makes sense to use it this way. Moreover, in the case of imported modules, we use the value of `latest_version` for `installed_version`. Fixes #23988 opw-1833522 --- addons/base_import_module/models/ir_module.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/addons/base_import_module/models/ir_module.py b/addons/base_import_module/models/ir_module.py index d9c3d4092a2..df7ad832d86 100644 --- a/addons/base_import_module/models/ir_module.py +++ b/addons/base_import_module/models/ir_module.py @@ -24,6 +24,13 @@ class IrModule(models.Model): imported = fields.Boolean(string="Imported Module") + @api.depends('name') + def _get_latest_version(self): + imported_modules = self.filtered(lambda m: m.imported and m.latest_version) + for module in imported_modules: + module.installed_version = module.latest_version + super(IrModule, self - imported_modules)._get_latest_version() + @api.multi def _import_module(self, module, path, force=False): known_mods = self.search([]) @@ -32,6 +39,8 @@ class IrModule(models.Model): terp = load_information_from_description_file(module, mod_path=path) values = self.get_values_from_terp(terp) + if 'version' in terp: + values['latest_version'] = terp['version'] unmet_dependencies = set(terp['depends']).difference(installed_mods)