From 69f6fcccd9cac7e601474b5d06561456f03dd34e Mon Sep 17 00:00:00 2001 From: sesn-odoo Date: Mon, 8 Jan 2024 12:50:33 +0100 Subject: [PATCH] [FIX] base_import_module: set actual ID for installed industries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently, when you attempt to uninstall an industry module, you are met with a 'record not found' error. Cause ----- The list of industry modules is fetched from `odoo.com`. Since they do not exist in the database, they are all assigned an ID of `-1`. This ends up causing an issue in case of uninstall because no record with and ID of `-1` can be found. Fix --- When a module is installed, it gets a record in the database (and ID). The fix simply uses that ID if it exists, instead of `-1`. opw-3662239 closes odoo/odoo#148456 Signed-off-by: Séna Serge Nshimiyimana (sesn) --- addons/base_import_module/models/ir_module.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/base_import_module/models/ir_module.py b/addons/base_import_module/models/ir_module.py index fabd42a8b48..ca1b92c966a 100644 --- a/addons/base_import_module/models/ir_module.py +++ b/addons/base_import_module/models/ir_module.py @@ -335,12 +335,12 @@ class IrModule(models.Model): resp.raise_for_status() modules_list = resp.json().get('result', []) for mod in modules_list: - mod['id'] = -1 module_name = mod.get('name', module_name) + existing_mod = self.search([('name', '=', module_name), ('state', '=', 'installed')]) + mod['id'] = existing_mod.id if existing_mod else -1 if 'icon' in fields: mod['icon'] = f"{APPS_URL}{mod['icon']}" if 'state' in fields: - existing_mod = self.search([('name', '=', module_name), ('state', '=', 'installed')]) if existing_mod: mod['state'] = 'installed' else: