diff options
| author | Nicolas Martinelli <nim@odoo.com> | 2018-04-20 17:27:49 +0200 |
|---|---|---|
| committer | Nicolas Martinelli <nim-odoo@users.noreply.github.com> | 2018-04-23 09:58:24 +0200 |
| commit | adfec4256100c7bd5cafe8c213f2012f06d8166a (patch) | |
| tree | bd5923883cd1995e230b23709dd2a31f59e978df /addons | |
| parent | 71862789f29752a39d1c1a0b25f76df74a975420 (diff) | |
[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
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/base_import_module/models/ir_module.py | 9 |
1 files changed, 9 insertions, 0 deletions
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) |
